package net.xiduth.net.decoders.handlers;

import java.text.NumberFormat;
import java.util.HashMap;
import java.util.List;
import java.util.TimerTask;

import net.xiduth.Settings;
import net.xiduth.cache.loaders.ItemDefinitions;
import net.xiduth.cores.CoresManager;
import net.xiduth.events.EventManager;
import net.xiduth.game.Animation;
import net.xiduth.game.CustomisedShop.MyShopItem;
import net.xiduth.game.Graphics;
import net.xiduth.game.World;
import net.xiduth.game.WorldTile;
import net.xiduth.game.item.Item;
import net.xiduth.game.minigames.Crucible;
import net.xiduth.game.minigames.duel.DuelArena;
import net.xiduth.game.minigames.duel.DuelControler;
import net.xiduth.game.npc.familiar.Familiar;
import net.xiduth.game.npc.familiar.Familiar.SpecialAttack;
import net.xiduth.game.player.CombatDefinitions;
import net.xiduth.game.player.EmotesManager;
import net.xiduth.game.player.Equipment;
import net.xiduth.game.player.Inventory;
import net.xiduth.game.player.Player;
import net.xiduth.game.player.Skills;
import net.xiduth.game.player.actions.FightPitsViewingOrb;
import net.xiduth.game.player.actions.HomeTeleport;
import net.xiduth.game.player.actions.Rest;
import net.xiduth.game.player.actions.Smithing.ForgingInterface;
import net.xiduth.game.player.actions.Summoning;
import net.xiduth.game.player.content.AdventurersLog;
import net.xiduth.game.player.content.Combat;
import net.xiduth.game.player.content.ItemConstants;
import net.xiduth.game.player.content.Magic;
import net.xiduth.game.player.content.PlayerDesign;
import net.xiduth.game.player.content.PlayerLook;
import net.xiduth.game.player.content.Runecrafting;
import net.xiduth.game.player.content.Shop;
import net.xiduth.game.player.content.SkillCapeCustomizer;
import net.xiduth.game.player.content.SkillsDialogue;
import net.xiduth.game.player.content.SlayerTask;
import net.xiduth.game.player.content.SpiritTree;
import net.xiduth.game.player.content.SummoningScroll;
import net.xiduth.game.player.content.TicketSystem;
import net.xiduth.game.player.content.agility.AgilityPoints;
import net.xiduth.game.player.content.artisan.ArtisanWorkshop;
import net.xiduth.game.player.content.events.interfaces.XiduthManagement;
import net.xiduth.game.player.content.exchange.ExchangeHandler;
import net.xiduth.game.player.content.tasks.Congrats;
import net.xiduth.game.player.content.tasks.TaskSystem;
import net.xiduth.game.player.dialogues.LevelUp;
import net.xiduth.game.player.dialogues.Transportation;
import net.xiduth.game.tasks.WorldTask;
import net.xiduth.game.tasks.WorldTasksManager;
import net.xiduth.io.InputStream;
import net.xiduth.net.decoders.WorldPacketsDecoder;
import net.xiduth.utils.FairyRing;
import net.xiduth.utils.Hiscores;
import net.xiduth.utils.ItemExamines;
import net.xiduth.utils.Logger;
import net.xiduth.utils.Misc;
import net.xiduth.utils.Utils;

public class ButtonHandler {
	static Player target;

	@SuppressWarnings("unused")
	public static void handleButtons(final Player player, InputStream stream,
			int packetId) {
		int interfaceHash = stream.readIntV2();
		int interfaceId = interfaceHash >> 16;
		if (Utils.getInterfaceDefinitionsSize() <= interfaceId) {
			// hack, or server error or client error
			// player.getSession().getChannel().close();
			return;
		}
		if (!World.containsLobbyPlayer(player.getUsername())) {
			if (player.isDead()
					|| !player.getInterfaceManager().containsInterface(
							interfaceId)) {
				return;
			}
		}
		final int componentId = interfaceHash - (interfaceId << 16);
		if (componentId != 65535
				&& Utils.getInterfaceDefinitionsComponentsSize(interfaceId) <= componentId) {
			// hack, or server error or client error
			// player.getSession().getChannel().close();
			return;
		}
		final int slotId2 = stream.readUnsignedShort128();
		final int slotId = stream.readUnsignedShortLE128();
		final int buttonId = interfaceHash - (interfaceId << 16);
		if (!player.getControlerManager().processButtonClick(interfaceId,
				componentId, slotId, packetId))
			return;
		if (player.getSquealOfFortune().handleButtons(interfaceId, buttonId,
				slotId, packetId))
			return;
		if (EventManager.handleButtonEvent(player, interfaceId, buttonId,
				packetId, slotId, slotId2)) {
			return;
		}
		switch (interfaceId) {
		case 1266:
			if (player.getAttributes().get("editting_own_store") != null) {
				if (componentId == 0) {
					switch (packetId) {
					case 14: // sell
						player.getAttributes().put("sending_mystore_item",
								slotId);
						player.getPackets()
								.sendRunScript(
										108,
										new Object[] { "How much do you want to sell this for?" });
						break;
					}
				}
				return;
			} else if (player.getAttributes().get("item_gamble") != null) {
				if (componentId == 0) {
					switch(packetId) {
					case 14: //Gamble Item
						player.getDialogueManager().startDialogue("GambleConfirm", slotId);
						break;
					}
				}
				return;
			}
			break;
		case 1171:
			if (player.getAttributes().get("editting_own_store") != null) {
				List<MyShopItem> items = player.getCustomisedShop()
						.getShopItems();
				if (slotId >= items.size()) {
					player.sendMessage("That item no longer exists in the shop!");
					return;
				}
				MyShopItem item = items.get(slotId);
				if (componentId == 7) {
					if (packetId == 14) {
						player.getCustomisedShop().removeItem(item, true);
						player.getInventory().addItem(item.getItem());
						player.getCustomisedShop().sendOwnShop();
					}
				}
				return;
			}
			Player target = (Player) player.getAttributes().get(
					"viewing_player_shop");
			if (target != null) {
				List<MyShopItem> items = target.getCustomisedShop()
						.getShopItems();
				if (slotId >= items.size()) {
					player.sendMessage("That item no longer exists in the shop!");
					return;
				}
				MyShopItem item = items.get(slotId);
				if (componentId == 7) {
					if (packetId == 14)
						player.sendMessage(item.getItem().getName() + " costs "
								+ Misc.format(item.getPrice()) + " coins in "
								+ target.getDisplayName() + "'s shop.");
					else {
						if (!World.containsPlayer(target.getUsername())) {
							player.sm("That player is not online to receive the money.");
							return;
						}
						if (player.takeMoney(item.getPrice())) {
							player.getInventory().addItem(item.getItem());
							target.getCustomisedShop().removeItem(item, false);
							target.getCustomisedShop().open(player);
						} else {
							player.sendMessage("You do not have enough coins to buy "
									+ item.getItem().getName()
									+ " from "
									+ target.getDisplayName() + "'s store!");
						}
					}
				}
			}
			break;
		}
		if (interfaceId == 548 || interfaceId == 746) {
			if ((interfaceId == 548 && componentId == 148)
					|| (interfaceId == 746 && componentId == 199)) {
				if (player.getInterfaceManager().containsScreenInter()
						|| player.getInterfaceManager()
								.containsInventoryInter()) {
					player.getPackets()
							.sendGameMessage(
									"Please finish what you're doing before opening the world map.");
					return;
				}
				// world map open
				player.getPackets().sendWindowsPane(755, 0);
				int posHash = player.getX() << 14 | player.getY();
				player.getPackets().sendGlobalConfig(622, posHash);
				player.getPackets().sendGlobalConfig(674, posHash);
			} else if (interfaceId == 578) { // Fairy Ring Warning
				if (componentId == 15) {
					FairyRing.warningInterface(player);
				} else if (componentId == 16) {
					player.closeInterfaces();
				}
			} else if (interfaceId == 734) { // Fairy rings
				if (componentId == 23) { // 1st Plus
					if (player.firstColumn == 2) {
						player.firstColumn = 4;
					} else if (player.firstColumn == 3) {
						player.firstColumn = 3;
					} else if (player.firstColumn >= 4) {
						player.firstColumn = 1;
					} else {
						player.firstColumn++;
					}
				} else if (componentId == 24) { // 1st Subtract
					if (player.firstColumn <= 1) {
						player.firstColumn = 4;
					} else {
						player.firstColumn--;
					}
				} else if (componentId == 25) { // 2nd Plus
					if (player.secondColumn == 2) {
						player.secondColumn = 4;
					} else if (player.secondColumn == 3) {
						player.secondColumn = 3;
					} else if (player.secondColumn >= 4) {
						player.secondColumn = 1;
					} else {
						player.secondColumn++;
					}
				} else if (componentId == 26) { // 2nd Subtract
					if (player.secondColumn <= 1) {
						player.secondColumn = 4;
					} else {
						player.secondColumn--;
					}
				} else if (componentId == 27) { // 3rd Plus
					if (player.thirdColumn == 2) {
						player.thirdColumn = 4;
					} else if (player.thirdColumn == 3) {
						player.thirdColumn = 3;
					} else if (player.thirdColumn >= 4) {
						player.thirdColumn = 1;
					} else {
						player.thirdColumn++;
					}
				} else if (componentId == 28) { // 3rd Subtract
					if (player.thirdColumn <= 1) {
						player.thirdColumn = 4;
					} else {
						player.thirdColumn--;
					}
				} else if (componentId == 21) { // Confirm
					FairyRing.ringTele(player, player.firstColumn,
							player.secondColumn, player.thirdColumn);
				}
			} else if (interfaceId == 734) {
				if (componentId == 23) {
					if (player.firstColumn == 2) {
						player.firstColumn = 4;
					} else if (player.firstColumn == 3) {
						player.firstColumn = 3;
					} else if (player.firstColumn >= 4) {
						player.firstColumn = 1;
					} else {
						player.firstColumn++;
					}
				} else if (componentId == 24) {
					if (player.firstColumn <= 1) {
						player.firstColumn = 4;
					} else {
						player.firstColumn--;
					}
				} else if (componentId == 25) {
					if (player.secondColumn == 2) {
						player.secondColumn = 4;
					} else if (player.secondColumn == 3) {
						player.secondColumn = 3;
					} else if (player.secondColumn >= 4) {
						player.secondColumn = 1;
					} else {
						player.secondColumn++;
					}
				} else if (componentId == 26) {
					if (player.secondColumn <= 1) {
						player.secondColumn = 4;
					} else {
						player.secondColumn--;
					}
				} else if (componentId == 27) {
					if (player.thirdColumn == 2) {
						player.thirdColumn = 4;
					} else if (player.thirdColumn == 3) {
						player.thirdColumn = 3;
					} else if (player.thirdColumn >= 4) {
						player.thirdColumn = 1;
					} else {
						player.thirdColumn++;
					}
				} else if (componentId == 28) {
					if (player.thirdColumn <= 1) {
						player.thirdColumn = 4;
					} else {
						player.thirdColumn--;
					}
				} else if (componentId == 21) { // Confirm
					FairyRing.ringTele(player, player.firstColumn,
							player.secondColumn, player.thirdColumn);
				}
			} else if (interfaceId == 746
					&& componentId == 207
					&& packetId == 14
					|| (interfaceId == 548 && componentId == 159 && packetId == 14)) {
				player.getMoneyPouch().toggle();

			} else if (interfaceId == 746
					&& componentId == 207
					&& packetId == 67
					|| (interfaceId == 548 && componentId == 159 && packetId == 67)) {
				player.getTemporaryAttributtes().put("money_pouch_remove",
						Boolean.TRUE);
				player.getPackets()
						.sendRunScript(
								108,
								new Object[] { "Your money pouch contains "
										+ NumberFormat.getInstance().format(
												player.getMoneyInPouch())
										+ " coins. How many would you like to withdraw?" });

				// Quests
			} else if ((interfaceId == 548 && componentId == 17)
					|| (interfaceId == 746 && componentId == 54)) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					player.getSkills().switchXPDisplay();
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getSkills().switchXPPopup();
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getSkills().setupXPCounter();
			}
		}

		else if (interfaceId == 1019) {
			if (componentId == 16)
				player.getPackets()
						.sendOpenURL(
								"http://xiduth.net/forums/index.php?/forum/36-bug-reports/");
			if (componentId == 18)
				TicketSystem.requestTicket(player);
		}

		if (interfaceId == 205) {
			TaskSystem.handleButtons(player, componentId);
		}
		if (interfaceId == 1160) {
			XiduthManagement.handleButtons(player, componentId);
		}
		if (interfaceId == 1174) {
			XiduthManagement.handleVoteRewards(player, componentId);
		}
		if (interfaceId == 797) {
			XiduthManagement.handleLucienOptions(player, componentId);
		}
		if (interfaceId == 864) {
		SpiritTree.handleButtons(player, slotId);
		}
		if (interfaceId == 1230) {
			Congrats.handleButtons(player, componentId);
		}

		if (interfaceId == 1028) {
			PlayerDesign.handle(player, componentId, slotId);
		}

		if (interfaceId == 378) {
			if (componentId == 15)
				SlayerTask.sendBuy(player);

			if (componentId == 76)
				player.getPackets().sendGameMessage(
						"This currently does not work.");

			if (componentId == 77)
				player.getPackets().sendGameMessage(
						"This currently does not work.");

			if (componentId == 14)
				player.getPackets().sendGameMessage(
						"This currently does not work");

			if (componentId == 73)
				player.getPackets().sendGameMessage(
						"This currently does not work.");

			if (componentId == 74)
				player.getPackets().sendGameMessage(
						"This currently does not work.");

			if (componentId == 75)
				player.getPackets().sendGameMessage(
						"This currently does not work.");

			if (componentId == 78)
				if (player.getSlayerPoints() >= 400) {
					player.getInventory().addItem(15492, 1);
					player.setSlayerPoints(player.getSlayerPoints() - 400);
					SlayerTask.sendLearn(player);
				} else {
					player.getPackets()
							.sendGameMessage(
									"You need 400 Slayer Points to purchase a Full Slayer Helm.");
				}
		}

		if (interfaceId == 164) {
			if (componentId == 24)
				if (player.getSlayerPoints() >= 400) {
					player.getSkills().addXp(Skills.SLAYER, 500);
					player.setSlayerPoints(player.getSlayerPoints() - 400);
					SlayerTask.sendBuy(player);
				} else {
					player.getPackets()
							.sendGameMessage(
									"You need 400 Slayer Points to purchase 10,000 experience.");
				}
			if (componentId == 26)
				if (player.getSlayerPoints() >= 75) {
					player.getInventory().addItem(13281, 1);
					player.setSlayerPoints(player.getSlayerPoints() - 75);
					SlayerTask.sendBuy(player);
				} else {
					player.getPackets()
							.sendGameMessage(
									"You need 75 Slayer Points to purchase a Ring of Slaying (8).");
				}
			if (componentId == 28)
				if (player.getSlayerPoints() >= 35) {
					player.getInventory().addItem(560, 250);
					player.getInventory().addItem(556, 750);
					player.setSlayerPoints(player.getSlayerPoints() - 35);
					SlayerTask.sendBuy(player);
				} else {
					player.getPackets()
							.sendGameMessage(
									"You need 35 Slayer Points to purchase runes for Slayer Dart.");
				}
			if (componentId == 37)
				if (player.getSlayerPoints() >= 35) {
					player.getInventory().addItem(13280, 250);
					player.setSlayerPoints(player.getSlayerPoints() - 35);
					SlayerTask.sendBuy(player);
				} else {
					player.getPackets()
							.sendGameMessage(
									"You need 35 Slayer Points to purchase Broad Bolts.");
				}
			if (componentId == 39)
				if (player.getSlayerPoints() >= 35) {
					player.getInventory().addItem(4160, 250);
					player.setSlayerPoints(player.getSlayerPoints() - 35);
					SlayerTask.sendBuy(player);
				} else {
					player.getPackets()
							.sendGameMessage(
									"You need 35 Slayer Points to purchase Broad Arrows.");
				}
			if (componentId == 16)
				SlayerTask.sendLearn(player);

			if (componentId == 17)
				player.getPackets().sendGameMessage("Currently does not work.");
		}

	/*	if (interfaceId == 1253) {
			player.getSquealOfFortune().handleButtons(player, componentId);
		} */

		if (interfaceId == 1072) {
			ArtisanWorkshop.handleButtons(player, componentId);
		}

		if (interfaceId == 6) {
			AgilityPoints.handleButtons(player, componentId);
		}

		if (interfaceId == 497) {
			if (componentId == 4)
				player.closeInterfaces();
		}

		if (interfaceId == 1252) {
			if (componentId == 3) {
			} else if (componentId == 5) {
				player.getPackets().closeInterface(
						player.getInterfaceManager().hasRezizableScreen() ? 11
								: 0);
				player.getPackets().sendGameMessage(
						"The icon will appear the next time you log in.");
			}
		}
	/*	if (interfaceId == 1252) {
			if (componentId == 3) {
				if (player.getSpins() == 0) {
					player.getPackets()
							.sendGameMessage(
									"You do not have enough Squeal of fortune spins to play.");
					return;
				}
			
				player.getSquealOfFortune().start();
			}
		}
*/
		if (interfaceId == 190 && componentId == 15) {
			if (slotId == 68) {
				if (player.spokeToWarrior == false
						&& player.spokeToShamus == false) {
					player.getInterfaceManager().sendInterface(275);
					player.getPackets().sendIComponentText(275, 1,
							"Lost-City Quest");
					player.getPackets().sendIComponentText(275, 10, "");
					player.getPackets().sendIComponentText(275, 11,
							"Speak to the Warrior West of Draynor");
					player.getPackets().sendIComponentText(275, 12,
							"<u>Requirements</u>");
					player.getPackets().sendIComponentText(275, 13,
							"<col=ffff00>31 Crafting, 36 Woodcutting</col>");
					player.getPackets().sendIComponentText(275, 14,
							"-=-Tips-=-");
					player.getPackets()
							.sendIComponentText(275, 15,
									"Use the 'Quests & Minigames' teleport at home to start the quest.");
					player.getPackets()
							.sendIComponentText(275, 16,
									"The lodestone works, remember to take full use of it.");
					player.getPackets()
							.sendIComponentText(275, 17,
									"You will need the skills required to complete the quest");
					player.getPackets()
							.sendIComponentText(275, 18,
									"The Monk Of Entrana removes everything in your inventory.");
					player.getPackets().sendIComponentText(275, 19, "");
					player.getPackets().sendIComponentText(275, 20, "");
				} else if (player.spokeToWarrior == true
						&& player.spokeToShamus == false) {
					player.getInterfaceManager().sendInterface(275);
					player.getPackets().sendIComponentText(275, 1,
							"Lost-City Quest");
					player.getPackets().sendIComponentText(275, 10, "");
					player.getPackets()
							.sendIComponentText(275, 11,
									"Shamus appears to be in one of the trees around this location.");
					player.getPackets()
							.sendIComponentText(275, 12,
									"The Warrior told me the tree displays 'Chop Tree'");
					player.getPackets().sendIComponentText(275, 13, "");
					player.getPackets().sendIComponentText(275, 14,
							"-=-Tips-=-");
					player.getPackets()
							.sendIComponentText(275, 15,
									"Use the 'Quests & Minigames' teleport at home to start the quest.");
					player.getPackets()
							.sendIComponentText(275, 16,
									"The lodestone works, remember to take full use of it.");
					player.getPackets()
							.sendIComponentText(275, 17,
									"You will need the skills required to complete the quest");
					player.getPackets()
							.sendIComponentText(275, 18,
									"The Monk Of Entrana removes everything in your inventory.");
					player.getPackets().sendIComponentText(275, 19, "");
					player.getPackets().sendIComponentText(275, 20, "");
				} else if (player.spokeToWarrior == true
						&& player.spokeToShamus == true) {
					player.getInterfaceManager().sendInterface(275);
					player.getPackets().sendIComponentText(275, 1,
							"Lost-City Quest");
					player.getPackets().sendIComponentText(275, 10, "");
					player.getPackets()
							.sendIComponentText(275, 11,
									"I should go find the Monk of Entrana, Who is located at Port Sarim.");
					player.getPackets().sendIComponentText(275, 12, "");
					player.getPackets().sendIComponentText(275, 13, "");
					player.getPackets().sendIComponentText(275, 14,
							"-=-Tips-=-");
					player.getPackets()
							.sendIComponentText(275, 15,
									"Use the 'Quests & Minigames' teleport at home to start the quest.");
					player.getPackets()
							.sendIComponentText(275, 16,
									"The lodestone works, remember to take full use of it.");
					player.getPackets()
							.sendIComponentText(275, 17,
									"You will need the skills required to complete the quest");
					player.getPackets()
							.sendIComponentText(275, 18,
									"The Monk Of Entrana removes everything in your inventory.");
					player.getPackets().sendIComponentText(275, 19, "");
					player.getPackets().sendIComponentText(275, 20, "");
				} else if (player.spokeToWarrior == true
						&& player.spokeToShamus == true
						&& player.spokeToMonk == true) {
					player.getInterfaceManager().sendInterface(275);
					player.getPackets().sendIComponentText(275, 1,
							"Lost-City Quest");
					player.getPackets()
							.sendIComponentText(275, 10,
									"The other side of Entrana is a ladder which leads to a cave");
					player.getPackets()
							.sendIComponentText(275, 11,
									"I should go down the ladder and search for the dramen tree.");
					player.getPackets()
							.sendIComponentText(275, 12,
									"In order to chop the dramen tree I must have a axe.");
					player.getPackets().sendIComponentText(275, 13,
							"The zombies must drop a axe of some sort.");
					player.getPackets().sendIComponentText(275, 14,
							"-=-Tips-=-");
					player.getPackets()
							.sendIComponentText(275, 15,
									"Use the 'Quests & Minigames' teleport at home to start the quest.");
					player.getPackets()
							.sendIComponentText(275, 16,
									"The lodestone works, remember to take full use of it.");
					player.getPackets()
							.sendIComponentText(275, 17,
									"You will need the skills required to complete the quest");
					player.getPackets()
							.sendIComponentText(275, 18,
									"The Monk Of Entrana removes everything in your inventory.");
					player.getPackets().sendIComponentText(275, 19, "");
					player.getPackets().sendIComponentText(275, 20, "");
				} else if (player.spokeToWarrior == true
						&& player.spokeToShamus == true
						&& player.spokeToMonk == true && player.lostCity == 1) {
					player.getInterfaceManager().sendInterface(275);
					player.getPackets().sendIComponentText(275, 1,
							"Lost-City Quest");
					player.getPackets().sendIComponentText(275, 10, "");
					player.getPackets().sendIComponentText(275, 11, "");
					player.getPackets().sendIComponentText(275, 12,
							"Congratulations Quest Complete!");
					player.getPackets().sendIComponentText(275, 13, "");
					player.getPackets().sendIComponentText(275, 14, "");
					player.getPackets().sendIComponentText(275, 15, "");
					player.getPackets().sendIComponentText(275, 16, "");
					player.getPackets().sendIComponentText(275, 17, "");
					player.getPackets().sendIComponentText(275, 18, "");
					player.getPackets().sendIComponentText(275, 19, "");
					player.getPackets().sendIComponentText(275, 20, "");
				}
			}
			if (slotId == 34) {
				player.getInterfaceManager().sendInterface(275);
				player.getPackets().sendIComponentText(275, 1,
						"Dwarf Cannon Quest");
				player.getPackets().sendIComponentText(275, 10, "");
				player.getPackets()
						.sendIComponentText(275, 11,
								"Speak to the Captain Lawgof at the Kingdom of Kandarin");
				player.getPackets().sendIComponentText(
						275,
						12,
						"I have fixed " + player.fixedRailings
								+ "/6 of the railings.");
				player.getPackets().sendIComponentText(275, 13, "");
				player.getPackets().sendIComponentText(275, 14, "");
				player.getPackets().sendIComponentText(275, 15, "");
				player.getPackets().sendIComponentText(275, 16, "");
				player.getPackets().sendIComponentText(275, 17, "");
				if (player.fixedRailings >= 6) {
					player.getPackets().sendIComponentText(
							275,
							12,
							"<str>I have fixed " + player.fixedRailings
									+ "/6 of the railings.");
				}
				if (player.completedRailingTask == true) {
					player.getPackets()
							.sendIComponentText(275, 14,
									"I should find 'Nulodion' who is located at the Dwarven Mine.");
				}
				if (player.completedDwarfCannonQuest == true) {
					player.getPackets()
							.sendIComponentText(275, 11,
									"<str>Speak to the Captain Lawgof at the Kingdom of Kandarin");
					player.getPackets()
							.sendIComponentText(275, 14,
									"<str>I should find 'Nulodion' who is located at the Dwarven Mine.");
					player.getPackets().sendIComponentText(275, 15, "");
					player.getPackets().sendIComponentText(275, 16,
							"<u>Quest Complete.</u>");
					player.getPackets()
							.sendIComponentText(275, 17,
									"Use a steel bar on any furnace to make cannonballs.");
					player.getPackets().sendIComponentText(275, 18,
							"You can now purchase a cannon from Nulodion.");
				}
				player.getPackets().sendIComponentText(275, 18, "");
				player.getPackets().sendIComponentText(275, 19, "");
				player.getPackets().sendIComponentText(275, 20, "");
			}
		}

		if (interfaceId == 1189 && componentId == 9) {
			player.closeInterfaces();
			player.getInterfaceManager().closeChatBoxInterface();
			player.getInterfaceManager().closeOverlay(true);
			player.getControlerManager().forceStop();
			return;
		}
		/* if (interfaceId == 1139) {
			if (componentId == 18) {
				if (player.getSpins() == 0) {
					player.getPackets()
							.sendGameMessage(
									"You do not have enough Squeal Of Fortune spins to play.");
					return;
				}
				player.getSquealOfFortune().start();
			}
			if (componentId == 23) {
				player.getPackets().sendOpenURL("LINK HERE TO BUY SPINS");
			}
		} */
		if (interfaceId == 548 && componentId == 68) {
			player.getPackets().sendIComponentText(1139, 10,
					" " + player.getSpins() + " ");
		}
		if (interfaceId == 1264) {
			if (componentId == 0) {
				player.closeInterfaces();
				player.getPackets().sendWindowsPane(
						player.getInterfaceManager().hasRezizableScreen() ? 746
								: 548, 0);
			}

			/**
			 * 
			 * Token Store.
			 * 
			 */
		} else if (interfaceId == 825) {
			Player player2 = player;
			switch (componentId) {
			case 93:
				if (player.getDungTokens() >= 30000) {
					player.getInventory().addItem(18349, 1);
					player.setDungTokens(player.getDungTokens() - 30000);
					player.getPackets()
							.sendGameMessage("Purchase successsful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 30,000 tokens to buy this!");
				}
				break;
			case 97:
				if (player.getDungTokens() >= 30000) {
					player.getInventory().addItem(18349, 1);
					player.setDungTokens(player.getDungTokens() - 30000);
					player.getPackets()
							.sendGameMessage("Purchase successsful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 30,000 tokens to buy this!");
				}
				break;
			case 101:
				if (player.getDungTokens() >= 30000) {
					player.getInventory().addItem(18353, 1);
					player.setDungTokens(player.getDungTokens() - 30000);
					player.getPackets()
							.sendGameMessage("Purchase successsful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 30,000 tokens to buy this!");
				}
				break;
			case 105:
				if (player.getDungTokens() >= 30000) {
					player.getInventory().addItem(18355, 1);
					player.setDungTokens(player.getDungTokens() - 30000);
					player.getPackets()
							.sendGameMessage("Purchase successsful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 30,000 tokens to buy this!");
				}
				break;
			case 109:
				if (player.getDungTokens() >= 30000) {
					player.getInventory().addItem(18357, 1);
					player.setDungTokens(player.getDungTokens() - 30000);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 30,000 tokens to buy this!");
				}
				break;
			case 113:
				if (player.getDungTokens() >= 30000) {
					player.getInventory().addItem(18359, 1);
					player.getInventory().addItem(18361, 1);
					player.setDungTokens(player.getDungTokens() - 30000);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 30,000 tokens to buy this!");
				}
				break;
			case 117:
				if (player.getDungTokens() >= 15000) {
					player.getInventory().addItem(18335, 1);
					player.setDungTokens(player.getDungTokens() - 15000);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 15,000 tokens to buy this!");
				}
				break;
			case 121:
				if (player.getDungTokens() >= 15000) {
					player.getInventory().addItem(19669, 1);
					player.setDungTokens(player.getDungTokens() - 15000);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 15,000 tokens to buy this!");
				}
				break;
			case 125:
				if (player.getDungTokens() >= 3000) {
					player.getInventory().addItem(23752, 1);
					player.setDungTokens(player.getDungTokens() - 3000);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 3,000 tokens to buy this!");
				}
				break;
			case 129:
				if (player.getDungTokens() >= 300) {
					player.getInventory().addItem(13727, 1);
					player.setDungTokens(player.getDungTokens() - 300);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 300 tokens to buy this!");
				}
				break;
			case 133:
				if (player.getDungTokens() >= 30000) {
					player.getInventory().addItem(14484, 1);
					player.setDungTokens(player.getDungTokens() - 30000);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 30,000 tokens to buy this!");
				}
				break;
			case 136:
				if (player.getDungTokens() >= 100000) {
					player.getInventory().addItem(23695, 1);
					player.setDungTokens(player.getDungTokens() - 100000);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 100,000 tokens to buy this!");
				}
				break;
			}

			/**
			 * 
			 * End of token store.
			 * 
			 */

			/**
			 * 
			 * 
			 * Troll Invasion rewards.
			 * 
			 * 
			 */

		} else if (interfaceId == 1011) {
			Player player2 = player;
			switch (componentId) {
			case 29:
				if (player.getTrollPoints() >= 5) {
					player.getBank().addItem(989, 1, true);
					player.setTrollPoints(player.getTrollPoints() - 5);
					player.getInterfaceManager().closeChatBoxInterface();
					player.getDialogueManager().startDialogue("SimpleMessage",
							"The item has been added to your bank.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 5 points to buy this!");
				}
				break;
			case 31:
				if (player.getTrollPoints() >= 10) {
					player.getBank().addItem(16, 1, true);
					player.setTrollPoints(player.getTrollPoints() - 10);
					player.getInterfaceManager().closeChatBoxInterface();
					player.getDialogueManager().startDialogue("SimpleMessage",
							"The item has been added to your bank.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 10 points to buy this!");
				}
				break;
			/**
			 * 
			 * Attack XP.
			 * 
			 */
			case 68:
				if (player.getTrollPoints() >= 1) {
					player.getSkills().addXp(Skills.ATTACK, 50);
					player.setTrollPoints(player.getTrollPoints() - 1);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 1 point to buy this!");
				}
				break;
			case 86:
				if (player.getTrollPoints() >= 10) {
					player.getSkills().addXp(Skills.ATTACK, 500);
					player.setTrollPoints(player.getTrollPoints() - 10);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 10 points to buy this!");
				}
				break;
			case 88:
				if (player.getTrollPoints() >= 100) {
					player.getSkills().addXp(Skills.ATTACK, 5000);
					player.setTrollPoints(player.getTrollPoints() - 100);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 100 points to buy this!");
				}
				break;
			/**
			 * 
			 * Strength XP.
			 * 
			 */
			case 100:
				if (player.getTrollPoints() >= 1) {
					player.getSkills().addXp(Skills.STRENGTH, 50);
					player.setTrollPoints(player.getTrollPoints() - 1);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 1 point to buy this!");
				}
				break;
			case 102:
				if (player.getTrollPoints() >= 10) {
					player.getSkills().addXp(Skills.STRENGTH, 500);
					player.setTrollPoints(player.getTrollPoints() - 10);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 10 points to buy this!");
				}
				break;
			case 104:
				if (player.getTrollPoints() >= 100) {
					player.getSkills().addXp(Skills.STRENGTH, 5000);
					player.setTrollPoints(player.getTrollPoints() - 100);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 100 points to buy this!");
				}
				break;

			/**
			 * 
			 * Defence XP.
			 * 
			 */
			case 116:
				if (player.getTrollPoints() >= 1) {
					player.getSkills().addXp(Skills.DEFENCE, 50);
					player.setTrollPoints(player.getTrollPoints() - 1);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 1 point to buy this!");
				}
				break;
			case 118:
				if (player.getTrollPoints() >= 10) {
					player.getSkills().addXp(Skills.DEFENCE, 500);
					player.setTrollPoints(player.getTrollPoints() - 10);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 10 points to buy this!");
				}
				break;
			case 120:
				if (player.getTrollPoints() >= 100) {
					player.getSkills().addXp(Skills.DEFENCE, 5000);
					player.setTrollPoints(player.getTrollPoints() - 100);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 100 points to buy this!");
				}
				break;
			/**
			 * 
			 * Consitution XP.
			 * 
			 */

			case 132:
				if (player.getTrollPoints() >= 1) {
					player.getSkills().addXp(Skills.HITPOINTS, 50);
					player.setTrollPoints(player.getTrollPoints() - 1);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 1 point to buy this!");
				}
				break;
			case 134:
				if (player.getTrollPoints() >= 10) {
					player.getSkills().addXp(Skills.HITPOINTS, 500);
					player.setTrollPoints(player.getTrollPoints() - 10);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 10 points to buy this!");
				}
				break;
			case 136:
				if (player.getTrollPoints() >= 100) {
					player.getSkills().addXp(Skills.HITPOINTS, 5000);
					player.setTrollPoints(player.getTrollPoints() - 100);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 100 points to buy this!");
				}
				break;
			/**
			 * 
			 * Ranged XP.
			 * 
			 * 
			 */
			case 148:
				if (player.getTrollPoints() >= 1) {
					player.getSkills().addXp(Skills.RANGE, 50);
					player.setTrollPoints(player.getTrollPoints() - 1);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 1 point to buy this!");
				}
				break;
			case 150:
				if (player.getTrollPoints() >= 10) {
					player.getSkills().addXp(Skills.RANGE, 500);
					player.setTrollPoints(player.getTrollPoints() - 10);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 10 points to buy this!");
				}
				break;
			case 152:
				if (player.getTrollPoints() >= 100) {
					player.getSkills().addXp(Skills.RANGE, 5000);
					player.setTrollPoints(player.getTrollPoints() - 100);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 100 points to buy this!");
				}
				break;
			/**
			 * 
			 * Magic XP.
			 * 
			 */
			case 164:
				if (player.getTrollPoints() >= 1) {
					player.getSkills().addXp(Skills.MAGIC, 50);
					player.setTrollPoints(player.getTrollPoints() - 1);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 1 point to buy this!");
				}
				break;
			case 166:
				if (player.getTrollPoints() >= 10) {
					player.getSkills().addXp(Skills.MAGIC, 500);
					player.setTrollPoints(player.getTrollPoints() - 10);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 10 points to buy this!");
				}
				break;
			case 168:
				if (player.getTrollPoints() >= 100) {
					player.getSkills().addXp(Skills.MAGIC, 5000);
					player.setTrollPoints(player.getTrollPoints() - 100);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 100 points to buy this!");
				}
				break;
			/**
			 * 
			 * Prayer XP.
			 * 
			 */
			case 180:
				if (player.getTrollPoints() >= 1) {
					player.getSkills().addXp(Skills.PRAYER, 50);
					player.setTrollPoints(player.getTrollPoints() - 1);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 1 point to buy this!");
				}
				break;
			case 182:
				if (player.getTrollPoints() >= 10) {
					player.getSkills().addXp(Skills.PRAYER, 500);
					player.setTrollPoints(player.getTrollPoints() - 10);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 10 points to buy this!");
				}
				break;
			case 184:
				if (player.getTrollPoints() >= 100) {
					player.getSkills().addXp(Skills.PRAYER, 5000);
					player.setTrollPoints(player.getTrollPoints() - 100);
					player.getPackets().sendGameMessage("Purchase successful.");
				} else {
					player.getPackets().sendGameMessage(
							"You need 100 points to buy this!");
				}
				break;
			}
		} else if (interfaceId == 182) {
			if (player.getInterfaceManager().containsInventoryInter())
				return;
			if (componentId == 6 || componentId == 13)
				if (!player.hasFinished())
					player.logout(componentId == 6);
			if (player.getRights() == 2)
				return;
			Hiscores.saveHighScore(player);
		} else if (interfaceId == 1165) {
		} else if (interfaceId == 880) {
			if (componentId >= 7 && componentId <= 19)
				Familiar.setLeftclickOption(player, (componentId - 7) / 2);
			else if (componentId == 21)
				Familiar.confirmLeftOption(player);
			else if (componentId == 25)
				Familiar.setLeftclickOption(player, 7);
		} else if (interfaceId == 662) {
			if (player.getFamiliar() == null) {
				if (player.getPet() == null) {
					return;
				}
				if (componentId == 49)
					player.getPet().call();
				else if (componentId == 51)
					player.getDialogueManager().startDialogue("DismissD");
				return;
			}
			if (componentId == 49)
				player.getFamiliar().call();
			else if (componentId == 51)
				player.getDialogueManager().startDialogue("DismissD");
			else if (componentId == 67)
				player.getFamiliar().takeBob();
			else if (componentId == 69)
				player.getFamiliar().renewFamiliar();
			else if (componentId == 74) {
				if (player.getFamiliar().getSpecialAttack() == SpecialAttack.CLICK)
					player.getFamiliar().setSpecial(true);
				if (player.getFamiliar().hasSpecialOn())
					player.getFamiliar().submitSpecial(player);
			}
		} else if (interfaceId == 747) {
			if (componentId == 8) {
				Familiar.selectLeftOption(player);
			} else if (player.getPet() != null) {
				if (componentId == 11 || componentId == 20) {
					player.getPet().call();
				} else if (componentId == 12 || componentId == 21) {
					player.getDialogueManager().startDialogue("DismissD");
				} else if (componentId == 10 || componentId == 19) {
					player.getPet().sendFollowerDetails();
				}
			} else if (player.getFamiliar() != null) {
				if (componentId == 11 || componentId == 20)
					player.getFamiliar().call();
				else if (componentId == 12 || componentId == 21)
					player.getDialogueManager().startDialogue("DismissD");
				else if (componentId == 13 || componentId == 22)
					player.getFamiliar().takeBob();
				else if (componentId == 14 || componentId == 23)
					player.getFamiliar().renewFamiliar();
				else if (componentId == 19 || componentId == 10)
					player.getFamiliar().sendFollowerDetails();
				else if (componentId == 18) {
					if (player.getFamiliar().getSpecialAttack() == SpecialAttack.CLICK)
						player.getFamiliar().setSpecial(true);
					if (player.getFamiliar().hasSpecialOn())
						player.getFamiliar().submitSpecial(player);
				}
			}
		} else if (interfaceId == 309)
			PlayerLook.handleHairdresserSalonButtons(player, componentId,
					slotId);
		else if (interfaceId == 729)
			PlayerLook.handleThessaliasMakeOverButtons(player, componentId,
					slotId);

		else if (interfaceId == 267) {
			switch (componentId) {

			case 24:
				if (player.getPlayerData().getInvasionPoints() >= 1) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 1);
					player.getSkills().addXp(Skills.ATTACK, 50);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased attack xp from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;
			case 49:
				if (player.getPlayerData().getInvasionPoints() >= 5) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 5);
					player.getSkills().addXp(Skills.ATTACK, 250);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased attack xp from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;
			case 56:
				if (player.getPlayerData().getInvasionPoints() >= 10) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 10);
					player.getSkills().addXp(Skills.ATTACK, 500);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased attack xp from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;

			case 35:
				if (player.getPlayerData().getInvasionPoints() >= 1) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 1);
					player.getSkills().addXp(Skills.STRENGTH, 50);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased strength xp from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;
			case 50:
				if (player.getPlayerData().getInvasionPoints() >= 5) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 5);
					player.getSkills().addXp(Skills.STRENGTH, 250);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased strength xp from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;
			case 57:
				if (player.getPlayerData().getInvasionPoints() >= 10) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 10);
					player.getSkills().addXp(Skills.STRENGTH, 500);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased strength xp from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;
			/*
			 * DEFENCE XP
			 */
			case 36:
				if (player.getPlayerData().getInvasionPoints() >= 1) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 1);
					player.getSkills().addXp(Skills.DEFENCE, 50);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased defence xp from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;
			case 51:
				if (player.getPlayerData().getInvasionPoints() >= 5) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 5);
					player.getSkills().addXp(Skills.DEFENCE, 250);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased defence xp from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;
			case 58:
				if (player.getPlayerData().getInvasionPoints() >= 10) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 10);
					player.getSkills().addXp(Skills.DEFENCE, 500);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased defence xp from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;
			/*
			 * RANGE XP
			 */
			case 37:
				if (player.getPlayerData().getInvasionPoints() >= 1) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 1);
					player.getSkills().addXp(Skills.RANGE, 50);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased range xp from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;
			case 52:
				if (player.getPlayerData().getInvasionPoints() >= 5) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 5);
					player.getSkills().addXp(Skills.RANGE, 250);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased range xp from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;
			case 59:
				if (player.getPlayerData().getInvasionPoints() >= 10) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 10);
					player.getSkills().addXp(Skills.RANGE, 500);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased range xp from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;
			/*
			 * MAGIC XP
			 */
			case 38:
				if (player.getPlayerData().getInvasionPoints() >= 1) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 1);
					player.getSkills().addXp(Skills.MAGIC, 50);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased magic xp from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;

			case 53:
				if (player.getPlayerData().getInvasionPoints() >= 5) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 5);
					player.getSkills().addXp(Skills.MAGIC, 250);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased magic xp from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;

			case 60:
				if (player.getPlayerData().getInvasionPoints() >= 10) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 10);
					player.getSkills().addXp(Skills.MAGIC, 500);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased magic xp from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;
			/*
			 * HITPOINTS XP
			 */
			case 39:
				if (player.getPlayerData().getInvasionPoints() >= 1) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 1);
					player.getSkills().addXp(Skills.HITPOINTS, 50);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased hitpoints(hp) xp from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;

			case 54:
				if (player.getPlayerData().getInvasionPoints() >= 5) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 5);
					player.getSkills().addXp(Skills.HITPOINTS, 250);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased hitpoints(hp) xp from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;

			case 61:
				if (player.getPlayerData().getInvasionPoints() >= 10) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 10);
					player.getSkills().addXp(Skills.HITPOINTS, 500);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased hitpoints(hp) xp from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;
			/*
			 * PRAYER XP
			 */
			case 40:
				if (player.getPlayerData().getInvasionPoints() >= 1) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 1);
					player.getSkills().addXp(Skills.PRAYER, 50);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased prayer xp from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;

			case 55:
				if (player.getPlayerData().getInvasionPoints() >= 5) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 5);
					player.getSkills().addXp(Skills.PRAYER, 250);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased prayer xp from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;

			case 62:
				if (player.getPlayerData().getInvasionPoints() >= 10) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 10);
					player.getSkills().addXp(Skills.PRAYER, 500);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased prayer xp from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;
			/*
			 * HERBS
			 */
			case 45:
				if (player.getPlayerData().getInvasionPoints() >= 15) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 15);
					int[] herbNoted = { 995, 960 }; // CHANGE THIS LATER ON TODO
					int[] amount = { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
							17, 18, 19, 20 };
					int herbReward = herbNoted[Utils
							.random(herbNoted.length - 1)];
					int herbAmount = amount[Utils.random(amount.length - 1)];
					player.getBank().addItem(herbReward, herbAmount, true);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased some herbs from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;
			/*
			 * ORE
			 */
			case 46:
				if (player.getPlayerData().getInvasionPoints() >= 15) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 15);
					int[] oreNoted = { 995, 960 }; // CHANGE THIS LATER ON TODO
					int[] amounts = { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
							16, 17, 18, 19, 20 };
					int oreReward = oreNoted[Utils.random(oreNoted.length - 1)];
					int oreAmount = amounts[Utils.random(amounts.length - 1)];
					player.getBank().addItem(oreReward, oreAmount, true);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased some ores from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;
			/*
			 * SEEDS
			 */
			case 48:
				if (player.getPlayerData().getInvasionPoints() >= 15) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 15);
					int[] seeds = { 995, 960 }; // CHANGE THIS LATER ON TODO
					int[] amountOfSeed = { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
							15, 16, 17, 18, 19, 20 };
					int seedsReward = seeds[Utils.random(seeds.length - 1)];
					int seedAmount = amountOfSeed[Utils
							.random(amountOfSeed.length - 1)];
					player.getBank().addItem(seedsReward, seedAmount, true);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased some seeds from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;
			/*
			 * VOID KNIGHT MACE
			 */
			case 41:
				if (player.getPlayerData().getInvasionPoints() >= 100) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 100);
					player.getBank().addItem(8841, 1, true);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased a Void Knight Mace from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;
			/*
			 * VOID KNIGHT TOP
			 */
			case 42:
				if (player.getPlayerData().getInvasionPoints() >= 100) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 100);
					player.getBank().addItem(8839, 1, true);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased a Void Knight Top from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;
			/*
			 * VOID KNIGHT ROBE
			 */
			case 43:
				if (player.getPlayerData().getInvasionPoints() >= 100) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 100);
					player.getBank().addItem(8840, 1, true);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased a Void Knight Robe from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;
			/*
			 * VOID KNIGHT GLOVES
			 */
			case 44:
				if (player.getPlayerData().getInvasionPoints() >= 100) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 100);
					player.getBank().addItem(8842, 1, true);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased a Void Knight Gloves from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;
			/*
			 * VOID MAGE HELM
			 */
			case 67:
				if (player.getPlayerData().getInvasionPoints() >= 100) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 100);
					player.getBank().addItem(11663, 1, true);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased a Void Mage Helm from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;
			/*
			 * VOID RANGE HELM
			 */
			case 68:
				if (player.getPlayerData().getInvasionPoints() >= 100) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 100);
					player.getBank().addItem(11664, 1, true);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased a Void Range Helm from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;
			/*
			 * VOID MELEE HELM
			 */
			case 69:
				if (player.getPlayerData().getInvasionPoints() >= 100) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 100);
					player.getBank().addItem(11665, 1, true);
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have purchased a Void Melee Helm from the Invasion shop and now have "
									+ player.getPlayerData()
											.getInvasionPoints() + " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;
			/*
			 * VOID KNIGHT COMMENDATION
			 */
			case 70:
				if (player.getPlayerData().getInvasionPoints() >= 5) {
					player.getPlayerData().setInvasionPoints(
							player.getPlayerData().getInvasionPoints() - 5);
					player.getBank().addItem(19642, 1, true);
					player.getDialogueManager()
							.startDialogue(
									"SimpleMessage",
									"You have purchased a Void Knight Commendation from the Invasion shop and now have "
											+ player.getPlayerData()
													.getInvasionPoints()
											+ " points.");
				} else {
					player.getPackets()
							.sendGameMessage(
									"Sorry, you don't have enough points to purchase this.");
				}
				break;
			/* END OF SHOP LIST */
			}
		}

		else if (interfaceId == 105) {
			// selling
			ExchangeHandler.handleButtons(player, 105, 32);
			ExchangeHandler.handleButtons(player, 105, 48);
			ExchangeHandler.handleButtons(player, 105, 64);
			ExchangeHandler.handleButtons(player, 105, 83);
			ExchangeHandler.handleButtons(player, 105, 102);
			ExchangeHandler.handleButtons(player, 105, 121);
			// buying
			ExchangeHandler.handleButtons(player, 105, 31);
			ExchangeHandler.handleButtons(player, 105, 47);
			ExchangeHandler.handleButtons(player, 105, 63);
			ExchangeHandler.handleButtons(player, 105, 82);
			ExchangeHandler.handleButtons(player, 105, 101);
			ExchangeHandler.handleButtons(player, 105, 120);
			ExchangeHandler.handleButtons(player, 105, 190);
			ExchangeHandler.handleButtons(player, 105, 186);
			ExchangeHandler.handleButtons(player, 105, 128);
			ExchangeHandler.handleButtons(player, 105, 157);
			ExchangeHandler.handleButtons(player, 105, 160);
			ExchangeHandler.handleButtons(player, 105, 155);
			ExchangeHandler.handleButtons(player, 105, 162);
			ExchangeHandler.handleButtons(player, 105, 164);
			ExchangeHandler.handleButtons(player, 105, 166);
			ExchangeHandler.handleButtons(player, 105, 168);
			ExchangeHandler.handleButtons(player, 105, 181);
			ExchangeHandler.handleButtons(player, 105, 175);
			ExchangeHandler.handleButtons(player, 105, 177);
			ExchangeHandler.handleButtons(player, 105, 179);
			ExchangeHandler.handleButtons(player, 105, 169);
			ExchangeHandler.handleButtons(player, 105, 171);
		} else if (interfaceId == 187) {
			if (componentId == 1) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					player.getMusicsManager().playAnotherMusic(slotId / 2);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getMusicsManager().sendHint(slotId / 2);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getMusicsManager().addToPlayList(slotId / 2);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.getMusicsManager().removeFromPlayList(slotId / 2);
			} else if (componentId == 4)
				player.getMusicsManager().addPlayingMusicToPlayList();
			else if (componentId == 10)
				player.getMusicsManager().switchPlayListOn();
			else if (componentId == 11)
				player.getMusicsManager().clearPlayList();
			else if (componentId == 13)
				player.getMusicsManager().switchShuffleOn();
		} else if (interfaceId == 275) {
			if (componentId == 14) {
				player.getPackets().sendOpenURL(Settings.WEBSITE_LINK);
			}
		} else if ((interfaceId == 590 && componentId == 8)
				|| interfaceId == 464) {
			player.getEmotesManager().useBookEmote(
					interfaceId == 464 ? componentId : EmotesManager.getId(
							slotId, packetId));
		} else if (interfaceId == 192) {
			if (componentId == 2)
				player.getCombatDefinitions().switchDefensiveCasting();
			else if (componentId == 7)
				player.getCombatDefinitions().switchShowCombatSpells();
			else if (componentId == 9)
				player.getCombatDefinitions().switchShowTeleportSkillSpells();
			else if (componentId == 11)
				player.getCombatDefinitions().switchShowMiscallaneousSpells();
			else if (componentId == 13)
				player.getCombatDefinitions().switchShowSkillSpells();
			else if (componentId >= 15 & componentId <= 17)
				player.getCombatDefinitions()
						.setSortSpellBook(componentId - 15);
			else
				Magic.processNormalSpell(player, componentId, packetId);
		} else if (interfaceId == 334) {
			if (componentId == 22)
				player.closeInterfaces();
			else if (componentId == 21)
				player.getTrade().accept(false);
		} else if (interfaceId == 335) {
			if (componentId == 18)
				player.getTrade().accept(true);
			else if (componentId == 20)
				player.closeInterfaces();
			else if (componentId == 53) {
				player.getAttributes().put("moneypouch_trade", true);
				player.getPackets()
						.sendRunScript(
								108,
								new Object[] { "How many coins would you like from your money pouch?" });
			} else if (componentId == 32) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					player.getTrade().removeItem(slotId, 1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getTrade().removeItem(slotId, 5);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getTrade().removeItem(slotId, 10);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.getTrade().removeItem(slotId, Integer.MAX_VALUE);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET) {
					player.getTemporaryAttributtes().put("trade_item_X_Slot",
							slotId);
					player.getTemporaryAttributtes().put("trade_isRemove",
							Boolean.TRUE);
					player.getPackets().sendRunScript(108,
							new Object[] { "Enter Amount:" });
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET)
					player.getTrade().sendValue(slotId, false);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getTrade().sendExamine(slotId, false);
			} else if (componentId == 35) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					player.getTrade().sendValue(slotId, true);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getTrade().sendExamine(slotId, true);
			}
		} else if (interfaceId == 336) {
			if (componentId == 0) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					player.getTrade().addItem(slotId, 1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getTrade().addItem(slotId, 5);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getTrade().addItem(slotId, 10);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.getTrade().addItem(slotId, Integer.MAX_VALUE);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET)
					player.getPackets().sendGameMessage(
							"A "
									+ new Item(slotId2, 1).getDefinitions()
											.getName().toLowerCase()
									+ "'s value is "
									+ ItemDefinitions.getItemDefinitions(
											slotId2).getValue() + " gold.");

				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET) {
					player.getTemporaryAttributtes().put("trade_item_X_Slot",
							slotId);
					player.getTemporaryAttributtes().remove("trade_isRemove");// put
																				// in
																				// by
																				// Google(kyle)
					player.getPackets().sendRunScript(108,
							new Object[] { "Enter Amount:" });
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET)
					player.getTrade().sendValue(slotId);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getInventory().sendExamine(slotId);
				else if(packetId == WorldPacketsDecoder.ACTION_BUTTON6_PACKET) {
//					player.getTemporaryAttributtes().put("lendingSlot", slotId);
//					player.getTemporaryAttributtes().put("lendhours", true);
//					player.getPackets().sendRunScript(108,
//						new Object[] { "How many hours would you like to lend the item for?" });
					player.getTrade().lendItem(slotId, 0);
				}
			}
		} else if (interfaceId == 300) {
			ForgingInterface.handleIComponents(player, componentId);
		} else if (interfaceId == 206) {
			if (componentId == 15) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					player.getPriceCheckManager().removeItem(slotId, 1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getPriceCheckManager().removeItem(slotId, 5);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getPriceCheckManager().removeItem(slotId, 10);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.getPriceCheckManager().removeItem(slotId,
							Integer.MAX_VALUE);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET) {
					player.getTemporaryAttributtes().put("pc_item_X_Slot",
							slotId);
					player.getTemporaryAttributtes().put("pc_isRemove",
							Boolean.TRUE);
					player.getPackets().sendRunScript(108,
							new Object[] { "Enter Amount:" });
				}
			}
		} else if (interfaceId == 672) {
			if (componentId == 16) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					Summoning.createPouch(player, slotId2, 1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					Summoning.createPouch(player, slotId2, 5);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					Summoning.createPouch(player, slotId2, 10);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					Summoning.createPouch(player, slotId2, Integer.MAX_VALUE);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET)
					Summoning.createPouch(player, slotId2, 28);// x
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON6_PACKET) {
					player.getPackets().sendGameMessage(
							"You currently need "
									+ ItemDefinitions.getItemDefinitions(
											slotId2)
											.getCreateItemRequirements());
				}
			}
			if (componentId == 19) {
				SummoningScroll.sendInterface(player);
			}

		} else if (interfaceId == 666) {
			if (componentId == 16) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					SummoningScroll.createScroll(player, slotId2, 1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					SummoningScroll.createScroll(player, slotId2, 5);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					SummoningScroll.createScroll(player, slotId2, 10);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					SummoningScroll.createScroll(player, slotId2,
							Integer.MAX_VALUE);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET)
					SummoningScroll.createScroll(player, slotId2, 28);// x
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON6_PACKET) {
					player.getPackets().sendGameMessage(
							"You currently need "
									+ ItemDefinitions.getItemDefinitions(
											slotId2)
											.getCreateItemRequirements());
				}
			}
			if (componentId == 18) {
				Summoning.sendInterface(player);
			}

		} else if (interfaceId == 207) {
			if (componentId == 0) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					player.getPriceCheckManager().addItem(slotId, 1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getPriceCheckManager().addItem(slotId, 5);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getPriceCheckManager().addItem(slotId, 10);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.getPriceCheckManager().addItem(slotId,
							Integer.MAX_VALUE);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET) {
					player.getTemporaryAttributtes().put("pc_item_X_Slot",
							slotId);
					player.getTemporaryAttributtes().remove("pc_isRemove");
					player.getPackets().sendRunScript(108,
							new Object[] { "Enter Amount:" });
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET)
					player.getInventory().sendExamine(slotId);
			}
		} else if (interfaceId == 665) {
			if (player.getFamiliar() == null
					|| player.getFamiliar().getBob() == null)
				return;
			if (componentId == 0) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					player.getFamiliar().getBob().addItem(slotId, 1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getFamiliar().getBob().addItem(slotId, 5);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getFamiliar().getBob().addItem(slotId, 10);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.getFamiliar().getBob()
							.addItem(slotId, Integer.MAX_VALUE);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET) {
					player.getTemporaryAttributtes().put("bob_item_X_Slot",
							slotId);
					player.getTemporaryAttributtes().remove("bob_isRemove");
					player.getPackets().sendRunScript(108,
							new Object[] { "Enter Amount:" });
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET)
					player.getInventory().sendExamine(slotId);
			}
		} else if(interfaceId == 1096){
			if(componentId == 120){
				player.getInterfaceManager().clanSettings();
			}else if(componentId == 386){
				player.getInterfaceManager().clanPermissions();
			}else if(componentId == 113){
				player.getInterfaceManager().clanMates();
			}
		}else if (interfaceId == 1110) {
		
			if (componentId == 82) {
				player.getPackets().cctest("" + player.getDisplayName() + "",
						"Xiduth");
			} else if (componentId == 78) {
				player.getInterfaceManager().clanSettings();
			} else if (componentId == 75){
				player.getInterfaceManager().clanDetails();
			}
		} else if (interfaceId == 299) {
			switch (componentId) {
			case 1:// Ape
				player.getNextWorldTile().setLocation(2755, 2784, 0);
				break;
			case 2:// Asgarnia
				player.getNextWorldTile().setLocation(3023, 3208, 0);
				break;
			case 3:// Karamja
				player.getNextWorldTile().setLocation(2948, 3147, 0);
				break;
			case 4:// Crandor
				player.getNextWorldTile().setLocation(2851, 3238, 0);
				break;
			case 5:// Entrana
				player.getNextWorldTile().setLocation(2834, 3335, 0);
				break;
			case 6:// Port
				player.getNextWorldTile().setLocation(3023, 3208, 0);
				break;
			case 7:// Sarim
				player.getNextWorldTile().setLocation(3023, 3208, 0);
				break;
			case 12:// Portk
				player.getNextWorldTile().setLocation(2665, 3161, 0);
				break;
			case 13: // Khazard
				player.getNextWorldTile().setLocation(2665, 3161, 0);
				break;
			case 14: // Ship
				player.sendMessage("Sorry the Map is missing from the cache ....");
				break;
			case 15: // Yard
				player.sendMessage("Sorry the Map is missing from the cache ....");
				break;
			case 18:// Cairn
				player.sendMessage("Sorry the Map is missing from the cache ....");
				break;
			case 19:// Isle
				player.sendMessage("Sorry the Map is missing from the cache ....");
				break;
			case 21:// Brimhaven Dungeon
				player.sendMessage("Sorry the Map BrimHaven is not input");
				player.sendMessage("You will be sent to Brimhaven dungeon use ladders to get to Brimhaven!");
				player.getNextWorldTile().setLocation(2710, 9466, 0);
				break;
			case 22:// Ardougne
				player.getNextWorldTile().setLocation(2662, 3305, 0);
				break;
			case 26:// Toll
				player.getNextWorldTile().setLocation(2755, 2784, 0);
				break;
			case 29:// Feldip
				player.sendMessage("You will be sent to Brimhaven dungeon use ladders to get to Brimhaven!");
				break;
			case 30:// Hills
				player.sendMessage("Error code 522 Map Coords Missing Developer Error!");
				break;
			}
		} else if (interfaceId == 671) {
			if (player.getFamiliar() == null
					|| player.getFamiliar().getBob() == null)
				return;
			if (componentId == 27) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					player.getFamiliar().getBob().removeItem(slotId, 1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getFamiliar().getBob().removeItem(slotId, 5);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getFamiliar().getBob().removeItem(slotId, 10);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.getFamiliar().getBob()
							.removeItem(slotId, Integer.MAX_VALUE);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET) {
					player.getTemporaryAttributtes().put("bob_item_X_Slot",
							slotId);
					player.getTemporaryAttributtes().put("bob_isRemove",
							Boolean.TRUE);
					player.getPackets().sendRunScript(108,
							new Object[] { "Enter Amount:" });
				}
			} else if (componentId == 29)
				player.getFamiliar().takeBob();
		} else if (interfaceId == 916) {
			SkillsDialogue.handleSetQuantityButtons(player, componentId);
		} else if (interfaceId == 193) {
			if (componentId == 5)
				player.getCombatDefinitions().switchShowCombatSpells();
			else if (componentId == 7)
				player.getCombatDefinitions().switchShowTeleportSkillSpells();
			else if (componentId >= 9 && componentId <= 11)
				player.getCombatDefinitions().setSortSpellBook(componentId - 9);
			else if (componentId == 18)
				player.getCombatDefinitions().switchDefensiveCasting();
			else
				Magic.processAncientSpell(player, componentId, packetId);
		} else if (interfaceId == 430) {
			if (componentId == 5)
				player.getCombatDefinitions().switchShowCombatSpells();
			else if (componentId == 7)
				player.getCombatDefinitions().switchShowTeleportSkillSpells();
			else if (componentId == 9)
				player.getCombatDefinitions().switchShowMiscallaneousSpells();
			else if (componentId >= 11 & componentId <= 13)
				player.getCombatDefinitions()
						.setSortSpellBook(componentId - 11);
			else if (componentId == 20)
				player.getCombatDefinitions().switchDefensiveCasting();
			else
				Magic.processLunarSpell(player, componentId, packetId);
		} else if (interfaceId == 261) {
			if (player.getInterfaceManager().containsInventoryInter())
				return;
			if (componentId == 22) {
				if (player.getInterfaceManager().containsScreenInter()) {
					player.getPackets()
							.sendGameMessage(
									"Please close the interface you have open before setting your graphic options.");
					return;
				}
				player.stopAll();
				player.getInterfaceManager().sendInterface(742);
			} else if (componentId == 11) {
				player.getPackets().sendConfig(1438, 1);
				player.allowsProfanity();
			} else if (componentId == 12)
				player.switchAllowChatEffects();
			else if (componentId == 13) { // chat setup
				player.getInterfaceManager().sendSettings(982);
			} else if (componentId == 14)
				player.switchMouseButtons();
			else if (componentId == 24) // audio options
				player.getInterfaceManager().sendSettings(429);
			else if (componentId == 26)
				AdventurersLog.open(player);
		} else if (interfaceId == 429) {
			if (componentId == 18)
				player.getInterfaceManager().sendSettings();
		} else if (interfaceId == 982) {
			if (componentId == 5)
				player.getInterfaceManager().sendSettings();
			else if (componentId == 41)
				player.setPrivateChatSetup(player.getPrivateChatSetup() == 0 ? 1
						: 0);
			else if (componentId >= 49 && componentId <= 66)
				player.setPrivateChatSetup(componentId - 48);
			else if (componentId >= 72 && componentId <= 91)
				player.setFriendChatSetup(componentId - 72);
		} else if (interfaceId == 271) {
			WorldTasksManager.schedule(new WorldTask() {
				@Override
				public void run() {
					if (componentId == 8 || componentId == 42)
						player.getPrayer().switchPrayer(slotId);

					else if (componentId == 43
							&& player.getPrayer().isUsingQuickPrayer())
						player.getPrayer().switchSettingQuickPrayer();
				}
			});
		} else if (interfaceId == 320) {
			player.stopAll();
			int lvlupSkill = -1;
			int skillMenu = -1;
			switch (componentId) {
			case 150: // Attack
				skillMenu = 1;
				if (player.getTemporaryAttributtes().remove("leveledUp[0]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 1);
				} else {
					lvlupSkill = 0;
					player.getPackets().sendConfig(1230, 10);
				}
				break;
			case 9: // Strength
				skillMenu = 2;
				if (player.getTemporaryAttributtes().remove("leveledUp[2]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 2);
				} else {
					lvlupSkill = 2;
					player.getPackets().sendConfig(1230, 20);
				}
				break;
			case 22: // Defence
				skillMenu = 5;
				if (player.getTemporaryAttributtes().remove("leveledUp[1]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 5);
				} else {
					lvlupSkill = 1;
					player.getPackets().sendConfig(1230, 40);
				}
				break;
			case 40: // Ranged
				skillMenu = 3;
				if (player.getTemporaryAttributtes().remove("leveledUp[4]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 3);
				} else {
					lvlupSkill = 4;
					player.getPackets().sendConfig(1230, 30);
				}
				break;
			case 58: // Prayer
				if (player.getTemporaryAttributtes().remove("leveledUp[5]") != Boolean.TRUE) {
					skillMenu = 7;
					player.getPackets().sendConfig(965, 7);
				} else {
					lvlupSkill = 5;
					player.getPackets().sendConfig(1230, 60);
				}
				break;
			case 71: // Magic
				if (player.getTemporaryAttributtes().remove("leveledUp[6]") != Boolean.TRUE) {
					skillMenu = 4;
					player.getPackets().sendConfig(965, 4);
				} else {
					lvlupSkill = 6;
					player.getPackets().sendConfig(1230, 33);
				}
				break;
			case 84: // Runecrafting
				if (player.getTemporaryAttributtes().remove("leveledUp[20]") != Boolean.TRUE) {
					skillMenu = 12;
					player.getPackets().sendConfig(965, 12);
				} else {
					lvlupSkill = 20;
					player.getPackets().sendConfig(1230, 100);
				}
				break;
			case 102: // Construction
				skillMenu = 22;
				if (player.getTemporaryAttributtes().remove("leveledUp[21]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 22);
				} else {
					lvlupSkill = 21;
					player.getPackets().sendConfig(1230, 698);
				}
				break;
			case 145: // Hitpoints
				skillMenu = 6;
				if (player.getTemporaryAttributtes().remove("leveledUp[3]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 6);
				} else {
					lvlupSkill = 3;
					player.getPackets().sendConfig(1230, 50);
				}
				break;
			case 15: // Agility
				skillMenu = 8;
				if (player.getTemporaryAttributtes().remove("leveledUp[16]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 8);
				} else {
					lvlupSkill = 16;
					player.getPackets().sendConfig(1230, 65);
				}
				break;
			case 28: // Herblore
				skillMenu = 9;
				if (player.getTemporaryAttributtes().remove("leveledUp[15]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 9);
				} else {
					lvlupSkill = 15;
					player.getPackets().sendConfig(1230, 75);
				}
				break;
			case 46: // Thieving
				skillMenu = 10;
				if (player.getTemporaryAttributtes().remove("leveledUp[17]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 10);
				} else {
					lvlupSkill = 17;
					player.getPackets().sendConfig(1230, 80);
				}
				break;
			case 64: // Crafting
				skillMenu = 11;
				if (player.getTemporaryAttributtes().remove("leveledUp[12]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 11);
				} else {
					lvlupSkill = 12;
					player.getPackets().sendConfig(1230, 90);
				}
				break;
			case 77: // Fletching
				skillMenu = 19;
				if (player.getTemporaryAttributtes().remove("leveledUp[9]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 19);
				} else {
					lvlupSkill = 9;
					player.getPackets().sendConfig(1230, 665);
				}
				break;
			case 90: // Slayer
				skillMenu = 20;
				if (player.getTemporaryAttributtes().remove("leveledUp[18]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 20);
				} else {
					lvlupSkill = 18;
					player.getPackets().sendConfig(1230, 673);
				}
				break;
			case 108: // Hunter
				skillMenu = 23;
				if (player.getTemporaryAttributtes().remove("leveledUp[22]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 23);
				} else {
					lvlupSkill = 22;
					player.getPackets().sendConfig(1230, 689);
				}
				break;
			case 140: // Mining
				skillMenu = 13;
				if (player.getTemporaryAttributtes().remove("leveledUp[14]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 13);
				} else {
					lvlupSkill = 14;
					player.getPackets().sendConfig(1230, 110);
				}
				break;
			case 135: // Smithing
				skillMenu = 14;
				if (player.getTemporaryAttributtes().remove("leveledUp[13]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 14);
				} else {
					lvlupSkill = 13;
					player.getPackets().sendConfig(1230, 115);
				}
				break;
			case 34: // Fishing
				skillMenu = 15;
				if (player.getTemporaryAttributtes().remove("leveledUp[10]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 15);
				} else {
					lvlupSkill = 10;
					player.getPackets().sendConfig(1230, 120);
				}
				break;
			case 52: // Cooking
				skillMenu = 16;
				if (player.getTemporaryAttributtes().remove("leveledUp[7]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 16);
				} else {
					lvlupSkill = 7;
					player.getPackets().sendConfig(1230, 641);
				}
				break;
			case 130: // Firemaking
				skillMenu = 17;
				if (player.getTemporaryAttributtes().remove("leveledUp[11]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 17);
				} else {
					lvlupSkill = 11;
					player.getPackets().sendConfig(1230, 649);
				}
				break;
			case 125: // Woodcutting
				skillMenu = 18;
				if (player.getTemporaryAttributtes().remove("leveledUp[8]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 18);
				} else {
					lvlupSkill = 8;
					player.getPackets().sendConfig(1230, 660);
				}
				break;
			case 96: // Farming
				skillMenu = 21;
				if (player.getTemporaryAttributtes().remove("leveledUp[19]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 21);
				} else {
					lvlupSkill = 19;
					player.getPackets().sendConfig(1230, 681);
				}
				break;
			case 114: // Summoning
				skillMenu = 24;
				if (player.getTemporaryAttributtes().remove("leveledUp[23]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 24);
				} else {
					lvlupSkill = 23;
					player.getPackets().sendConfig(1230, 705);
				}
				break;
			case 120: // Dung
				skillMenu = 25;
				if (player.getTemporaryAttributtes().remove("leveledUp[24]") != Boolean.TRUE) {
					player.getPackets().sendConfig(965, 25);
				} else {
					lvlupSkill = 24;
					player.getPackets().sendConfig(1230, 705);
				}
				break;
			}

			/*
			 * player.getInterfaceManager().sendInterface( lvlupSkill != -1 ?
			 * 741 : 499);
			 */
			player.getInterfaceManager().sendScreenInterface(317, 1218);
			player.getPackets().sendInterface(false, 1218, 1, 1217); // seems to
																		// fix
			if (lvlupSkill != -1)
				LevelUp.switchFlash(player, lvlupSkill, false);
			if (skillMenu != -1)
				player.getTemporaryAttributtes().put("skillMenu", skillMenu);
		} else if (interfaceId == 1218) {
			if ((componentId >= 33 && componentId <= 55) || componentId == 120
					|| componentId == 151 || componentId == 189)
				player.getPackets().sendInterface(false, 1218, 1, 1217); // seems
																			// to
																			// fix
		} else if (interfaceId == 499) {
			int skillMenu = -1;
			if (player.getTemporaryAttributtes().get("skillMenu") != null)
				skillMenu = (Integer) player.getTemporaryAttributtes().get(
						"skillMenu");
			if (componentId >= 10 && componentId <= 25)
				player.getPackets().sendConfig(965,
						((componentId - 10) * 1024) + skillMenu);
			else if (componentId == 29)
				// close inter
				player.stopAll();

		} else if (interfaceId == 387) {
			if (player.getInterfaceManager().containsInventoryInter())
				return;
			if (componentId == 6) {
				player.stopAll();
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET) {
					int hatId = player.getEquipment().getHatId();
					if (hatId == 24437 || hatId == 24439 || hatId == 24440
							|| hatId == 24441) {
						player.getDialogueManager().startDialogue(
								"FlamingSkull",
								player.getEquipment().getItem(
										Equipment.SLOT_HAT), -1);
						return;
					}
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					ButtonHandler.sendRemove(player, Equipment.SLOT_HAT);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getEquipment().sendExamine(Equipment.SLOT_HAT);
			} else if (componentId == 9) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET) {
					int capeId = player.getEquipment().getCapeId();
					if (capeId == 20769 || capeId == 20771) {
						player.setNextAnimation(new Animation(8502));
						player.setNextGraphics(new Graphics(1308));
						player.getPackets()
								.sendGameMessage(
										"You restored your Summoning points with the Completionist cape!",
										true);
					}
				}
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET) {
					int capeId = player.getEquipment().getCapeId();
					if (capeId == 20769 || capeId == 20771)
						SkillCapeCustomizer.startCustomizing(player, capeId);
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET) {
					int capeId = player.getEquipment().getCapeId();
					if (capeId == 20767)
						SkillCapeCustomizer.startCustomizing(player, capeId);
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					ButtonHandler.sendRemove(player, Equipment.SLOT_CAPE);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getEquipment().sendExamine(Equipment.SLOT_CAPE);
			} else if (componentId == 12) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET) {
					int amuletId = player.getEquipment().getAmuletId();
					if (amuletId <= 1712 && amuletId >= 1706
							|| amuletId >= 10354 && amuletId <= 10361) {
						if (Magic.sendItemTeleportSpell(player, true,
								Transportation.EMOTE, Transportation.GFX, 4,
								new WorldTile(3087, 3496, 0))) {
							Item amulet = player.getEquipment().getItem(
									Equipment.SLOT_AMULET);
							if (amulet != null) {
								amulet.setId(amulet.getId() - 2);
								player.getEquipment().refresh(
										Equipment.SLOT_AMULET);
							}
						}
					} else if (amuletId == 1704)
						player.getPackets()
								.sendGameMessage(
										"The amulet has ran out of charges. You need to recharge it if you wish it use it once more.");
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET) {
					int amuletId = player.getEquipment().getAmuletId();
					if (amuletId <= 1712 && amuletId >= 1706
							|| amuletId >= 10354 && amuletId <= 10361) {
						if (Magic.sendItemTeleportSpell(player, true,
								Transportation.EMOTE, Transportation.GFX, 4,
								new WorldTile(2918, 3176, 0))) {
							Item amulet = player.getEquipment().getItem(
									Equipment.SLOT_AMULET);
							if (amulet != null) {
								amulet.setId(amulet.getId() - 2);
								player.getEquipment().refresh(
										Equipment.SLOT_AMULET);
							}
						}
					}
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET) {
					int amuletId = player.getEquipment().getAmuletId();
					if (amuletId <= 1712 && amuletId >= 1706
							|| amuletId >= 10354 && amuletId <= 10361) {
						if (Magic.sendItemTeleportSpell(player, true,
								Transportation.EMOTE, Transportation.GFX, 4,
								new WorldTile(3105, 3251, 0))) {
							Item amulet = player.getEquipment().getItem(
									Equipment.SLOT_AMULET);
							if (amulet != null) {
								amulet.setId(amulet.getId() - 2);
								player.getEquipment().refresh(
										Equipment.SLOT_AMULET);
							}
						}
					}
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET) {
					int amuletId = player.getEquipment().getAmuletId();
					if (amuletId <= 1712 && amuletId >= 1706
							|| amuletId >= 10354 && amuletId <= 10361) {
						if (Magic.sendItemTeleportSpell(player, true,
								Transportation.EMOTE, Transportation.GFX, 4,
								new WorldTile(3293, 3163, 0))) {
							Item amulet = player.getEquipment().getItem(
									Equipment.SLOT_AMULET);
							if (amulet != null) {
								amulet.setId(amulet.getId() - 2);
								player.getEquipment().refresh(
										Equipment.SLOT_AMULET);
							}
						}
					}
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					ButtonHandler.sendRemove(player, Equipment.SLOT_AMULET);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getEquipment().sendExamine(Equipment.SLOT_AMULET);
			} else if (componentId == 15) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					ButtonHandler.sendRemove(player, Equipment.SLOT_WEAPON);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getEquipment().sendExamine(Equipment.SLOT_WEAPON);
				int weaponId = player.getEquipment().getWeaponId();
				{
					if (weaponId == 15484)
						player.getInterfaceManager().gazeOrbOfOculus();
				}

			} else if (componentId == 18) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					ButtonHandler.sendRemove(player, Equipment.SLOT_CHEST);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getEquipment().sendExamine(Equipment.SLOT_CHEST);
			} else if (componentId == 21) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					ButtonHandler.sendRemove(player, Equipment.SLOT_SHIELD);
				else if (componentId == 21 && packetId == 67
						&& player.getEquipment().getShieldId() == 11283
						&& player.DFS >= 1)
					Combat.hasDragonFire(player);// TODO
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getEquipment().sendExamine(Equipment.SLOT_SHIELD);
			} else if (componentId == 24) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					ButtonHandler.sendRemove(player, Equipment.SLOT_LEGS);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getEquipment().sendExamine(Equipment.SLOT_LEGS);
			} else if (componentId == 27) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					ButtonHandler.sendRemove(player, Equipment.SLOT_HANDS);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getEquipment().sendExamine(Equipment.SLOT_HANDS);
			} else if (componentId == 30) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					ButtonHandler.sendRemove(player, Equipment.SLOT_FEET);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getEquipment().sendExamine(Equipment.SLOT_FEET);
			} else if (componentId == 33) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					ButtonHandler.sendRemove(player, Equipment.SLOT_RING);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getEquipment().sendExamine(Equipment.SLOT_RING);
			} else if (componentId == 36) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					ButtonHandler.sendRemove(player, Equipment.SLOT_ARROWS);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getEquipment().sendExamine(Equipment.SLOT_ARROWS);
			} else if (componentId == 45) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET) {
					ButtonHandler.sendRemove(player, Equipment.SLOT_AURA);
					player.getAuraManager().removeAura();
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getEquipment().sendExamine(Equipment.SLOT_AURA);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getAuraManager().activate();
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getAuraManager().sendAuraRemainingTime();
			} else if (componentId == 37) {
				openEquipmentBonuses(player, false);
			} else if (interfaceId == 679 && packetId == 5
					&& player.getInventory().containsItem(11283, 1)) {
				InventoryOptionsHandler.DFS(player, slotId2, 11283);
			} else if (componentId == 40) {
				player.stopAll();
				player.getInterfaceManager().sendInterface(17);
			} else if (componentId == 41) {
				player.stopAll();
				player.getInterfaceManager().sendInterface(1178);
			}
		} else if (interfaceId == 1265) {
			Shop shop = (Shop) player.getTemporaryAttributtes().get("Shop");
			if (shop == null)
				return;
			Integer slot = (Integer) player.getTemporaryAttributtes().get(
					"ShopSelectedSlot");
			boolean isBuying = player.getTemporaryAttributtes().get(
					"shop_buying") != null;
			if (componentId == 20) {
				player.getTemporaryAttributtes()
						.put("ShopSelectedSlot", slotId);
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					shop.sendInfo(player, slotId, isBuying);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					shop.handleShop(player, slotId, 1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					shop.handleShop(player, slotId, 5);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					shop.handleShop(player, slotId, 10);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET)
					shop.handleShop(player, slotId, 50);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET)
					shop.handleShop(player, slotId, 500);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					shop.sendExamine(player, slotId);
			} else if (componentId == 201) {
				shop.buy(player, slotId, 1);
			} else if (componentId == 29) {
				player.getPackets().sendConfig(2561, 93);
				player.getTemporaryAttributtes().remove("shop_buying");
				shop.setAmount(player, 1);
			} else if (componentId == 28) {
				player.getTemporaryAttributtes().put("shop_buying", true);
				shop.setAmount(player, 1);
			}
		} else if (interfaceId == 1266) {
			if (componentId == 0) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET)
					player.getInventory().sendExamine(slotId);
				else {
					Shop shop = (Shop) player.getTemporaryAttributtes().get(
							"Shop");
					if (shop == null)
						return;
					player.getPackets().sendConfig(2563, slotId);
					if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
						shop.sendValue(player, slotId);
					else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
						shop.sell(player, slotId, 1);
					else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
						shop.sell(player, slotId, 5);
					else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
						shop.sell(player, slotId, 10);
					else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET)
						shop.sell(player, slotId, 50);
				}
			}
		} else if (interfaceId == 640) {
			if (componentId == 18 || componentId == 22) {
				player.getTemporaryAttributtes().put("WillDuelFriendly", true);
				player.getPackets().sendConfig(283, 67108864);
			} else if (componentId == 19 || componentId == 21) {
				player.getTemporaryAttributtes().put("WillDuelFriendly", false);
				player.getPackets().sendConfig(283, 134217728);
			} else if (componentId == 20) {
				DuelControler.challenge(player);
			}
		} else if (interfaceId == 650) {
			if (componentId == 15) {
				player.stopAll();
				player.setNextWorldTile(new WorldTile(2974, 4384, player
						.getPlane()));
				player.getControlerManager().startControler(
						"CorpBeastControler");
			} else if (componentId == 16)
				player.closeInterfaces();
		} else if (interfaceId == 667) {
			if (componentId == 14) {
				if (slotId >= 14)
					return;
				Item item = player.getEquipment().getItem(slotId);
				if (item == null)
					return;
				if (packetId == 3)
					player.getPackets().sendGameMessage(
							ItemExamines.getExamine(item));
				else if (packetId == 216) {
					sendRemove(player, slotId);
					ButtonHandler.refreshEquipBonuses(player);
				}
			} else if (componentId == 46
					&& player.getTemporaryAttributtes().remove("Banking") != null) {
				player.getBank().openBank();
			}
		} else if (interfaceId == 670) {
			if (componentId == 0) {
				if (slotId >= player.getInventory().getItemsContainerSize())
					return;
				Item item = player.getInventory().getItem(slotId);
				if (item == null)
					return;
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET) {
					if (sendWear(player, slotId, item.getId()))
						ButtonHandler.refreshEquipBonuses(player);
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.getInventory().sendExamine(slotId);
			}
		} else if (interfaceId == Inventory.INVENTORY_INTERFACE) { // inventory
			if (componentId == 0) {
				if (slotId > 27
						|| player.getInterfaceManager()
								.containsInventoryInter())
					return;
				Item item = player.getInventory().getItem(slotId);
				if (item == null || item.getId() != slotId2)
					return;
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					InventoryOptionsHandler.handleItemOption1(player, slotId,
							slotId2, item);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					InventoryOptionsHandler.handleItemOption2(player, slotId,
							slotId2, item);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					InventoryOptionsHandler.handleItemOption3(player, slotId,
							slotId2, item);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					InventoryOptionsHandler.handleItemOption4(player, slotId,
							slotId2, item);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET)
					InventoryOptionsHandler.handleItemOption5(player, slotId,
							slotId2, item);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON6_PACKET)
					InventoryOptionsHandler.handleItemOption6(player, slotId,
							slotId2, item);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON7_PACKET)
					InventoryOptionsHandler.handleItemOption7(player, slotId,
							slotId2, item);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					InventoryOptionsHandler.handleItemOption8(player, slotId,
							slotId2, item);
			}
		} else if (interfaceId == 742) {
			if (componentId == 46) // close
				player.stopAll();
		} else if (interfaceId == 1253) {
			if (componentId == 0) // close
				player.stopAll();
		} else if (interfaceId == 743) {
			if (componentId == 20) // close
				player.stopAll();
		} else if (interfaceId == 741) {
			if (componentId == 9) // close
				player.stopAll();
		}else if (interfaceId == 749) {
				if (componentId == 4) {
					if (((player.getControlerManager().getControler() instanceof DuelControler))
							|| ((player.getControlerManager().getControler() instanceof DuelArena))) {
						player.out("You can't use Quick Prayers here.");
						return;
					} else if ((packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET))// activate
						player.getPrayer().switchQuickPrayers();
					else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET) // switch
						player.getPrayer().switchSettingQuickPrayer();
				}
			}
		 else if (interfaceId == 750) {
			if (componentId == 4) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET) {
					player.toogleRun(player.isResting() ? false : true);
					if (player.isResting())
						player.stopAll();
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET) {
					if (player.isResting()) {
						player.stopAll();
						return;
					}
					long currentTime = Utils.currentTimeMillis();
					if (player.getEmotesManager().getNextEmoteEnd() >= currentTime) {
						player.getPackets().sendGameMessage(
								"You can't rest while perfoming an emote.");
						return;
					}
					if (player.getLockDelay() >= currentTime) {
						player.getPackets().sendGameMessage(
								"You can't rest while perfoming an action.");
						return;
					}
					player.stopAll();
					player.getActionManager().setAction(new Rest());
				}
			}
		} else if (interfaceId == 11) {
			if (componentId == 17) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					player.getBank().depositItem(slotId, 1, false);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getBank().depositItem(slotId, 5, false);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getBank().depositItem(slotId, 10, false);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.getBank().depositItem(slotId, Integer.MAX_VALUE,
							false);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET) {
					player.getTemporaryAttributtes().put("bank_item_X_Slot",
							slotId);
					player.getTemporaryAttributtes().remove("bank_isWithdraw");
					player.getPackets().sendRunScript(108,
							new Object[] { "Enter Amount:" });
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET)
					player.getInventory().sendExamine(slotId);
			} else if (componentId == 18)
				player.getBank().depositAllInventory(false);
			else if (componentId == 20)
				player.getBank().depositAllEquipment(false);
		} else if (interfaceId == 762) {
			if (componentId == 15)
				player.getBank().switchInsertItems();
			else if (componentId == 19)
				player.getBank().switchWithdrawNotes();
			else if (componentId == 33)
				player.getBank().depositAllInventory(true);
			else if (componentId == 35) {
			} else if (componentId == 37)
				player.getBank().depositAllEquipment(true);
			else if (componentId == 46) {
				player.closeInterfaces();
				player.getInterfaceManager().sendInterface(767);
				player.setCloseInterfacesEvent(new Runnable() {
					@Override
					public void run() {
						player.getBank().openBank();
					}
				});
			} else if (componentId >= 46 && componentId <= 64) {
				int tabId = 9 - ((componentId - 46) / 2);
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					player.getBank().setCurrentTab(tabId);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getBank().collapse(tabId);
			} else if (componentId == 95) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					player.getBank().withdrawItem(slotId, 1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getBank().withdrawItem(slotId, 5);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getBank().withdrawItem(slotId, 10);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.getBank().withdrawLastAmount(slotId);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET) {
					player.getTemporaryAttributtes().put("bank_item_X_Slot",
							slotId);
					player.getTemporaryAttributtes().put("bank_isWithdraw",
							Boolean.TRUE);
					player.getPackets().sendRunScript(108,
							new Object[] { "Enter Amount:" });
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET)
					player.getBank().withdrawItem(slotId, Integer.MAX_VALUE);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON6_PACKET)
					player.getBank().withdrawItemButOne(slotId);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getBank().sendExamine(slotId);

			} else if (componentId == 119) {
				openEquipmentBonuses(player, true);
			}
		} else if (interfaceId == 190) {
			if (componentId == 15) {
				if (slotId == 170) {
					player.getInterfaceManager().sendInterface(1245);
					player.getPackets().sendIComponentText(1245, 15,
							"The Blood Pact");
				} else if (slotId == 1) {
					player.getInterfaceManager().sendInterface(1245);
					player.getPackets().sendIComponentText(1245, 15,
							"Cook's Assistant");
				}
			}
		} else if (interfaceId == 763) {
			if (componentId == 0) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
					player.getBank().depositItem(slotId, 1, true);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getBank().depositItem(slotId, 5, true);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getBank().depositItem(slotId, 10, true);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.getBank().depositLastAmount(slotId);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET) {
					player.getTemporaryAttributtes().put("bank_item_X_Slot",
							slotId);
					player.getTemporaryAttributtes().remove("bank_isWithdraw");
					player.getPackets().sendRunScript(108,
							new Object[] { "Enter Amount:" });
				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET)
					player.getBank().depositItem(slotId, Integer.MAX_VALUE,
							true);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON8_PACKET)
					player.getInventory().sendExamine(slotId);
			}
		} else if (interfaceId == 767) {
			if (componentId == 10)
				player.getBank().openBank();
		} else if (interfaceId == 884) {
			if (componentId == 4) {
				int weaponId = player.getEquipment().getWeaponId();
				if (player.hasInstantSpecial(weaponId)) {
					player.performInstantSpecial(weaponId);
					return;
				}
				submitSpecialRequest(player);
			} else if (componentId >= 7 && componentId <= 10)
				player.getCombatDefinitions().setAttackStyle(componentId - 7);
			else if (componentId == 11)
				player.getCombatDefinitions().switchAutoRelatie();
		} else if (interfaceId == 755) {
			if (componentId == 44)
				player.getPackets().sendWindowsPane(
						player.getInterfaceManager().hasRezizableScreen() ? 746
								: 548, 2);
			else if (componentId == 42) {
				player.getHintIconsManager().removeAll();
				player.getPackets().sendConfig(1159, 1);
			}
		} else if (interfaceId == 20)
			SkillCapeCustomizer.handleSkillCapeCustomizer(player, componentId);
		else if (interfaceId == 1056) {
			if (componentId == 173)
				player.getInterfaceManager().sendInterface(917);
		} else if (interfaceId == 751) {
			if (componentId == 26) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getFriendsIgnores().setPrivateStatus(0);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getFriendsIgnores().setPrivateStatus(1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.getFriendsIgnores().setPrivateStatus(2);
			} else if (componentId == 32) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.setFilterGame(false);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.setFilterGame(true);
			} else if (componentId == 14) {
				player.getInterfaceManager().sendInterface(594);
			} else if (componentId == 29) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.setPublicStatus(0);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.setPublicStatus(1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.setPublicStatus(2);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET)
					player.setPublicStatus(3);
			} else if (componentId == 0) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.getFriendsIgnores().setFriendsChatStatus(0);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.getFriendsIgnores().setFriendsChatStatus(1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.getFriendsIgnores().setFriendsChatStatus(2);
			} else if (componentId == 23) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.setClanStatus(0);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.setClanStatus(1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.setClanStatus(2);
			} else if (componentId == 20) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.setTradeStatus(0);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.setTradeStatus(1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.setTradeStatus(2);
			} else if (componentId == 17) {
				if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
					player.setAssistStatus(0);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
					player.setAssistStatus(1);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
					player.setAssistStatus(2);
				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET) {
					// ASSIST XP Earned/Time
				}
			}
		} else if (interfaceId == 1163 || interfaceId == 1164
				|| interfaceId == 1168 || interfaceId == 1170
				|| interfaceId == 1173)
			player.getDominionTower().handleButtons(interfaceId, componentId);
		else if (interfaceId == 900)
			PlayerLook.handleMageMakeOverButtons(player, componentId);
		else if(interfaceId == 1107){
		if(componentId == 136){
			player.getPackets().sendOpenURL("http://www.forum.xiduth.com/");}}
		else if (interfaceId == 1108 || interfaceId == 1109)
			player.getFriendsIgnores().handleFriendChatButtons(interfaceId,
					componentId, packetId);
		else if (interfaceId == 1079)
			player.closeInterfaces();
		else if (interfaceId == 374) {
			if (componentId >= 5 && componentId <= 9)
				player.setNextWorldTile(new WorldTile(
						FightPitsViewingOrb.ORB_TELEPORTS[componentId - 5]));
			else if (componentId == 15)
				player.stopAll();
		} else if (interfaceId == 1092) {
			player.stopAll();
			WorldTile destTile = null;
			switch (componentId) {
			case 47:
				destTile = HomeTeleport.LUMBRIDGE_LODE_STONE;
				break;
			case 42:
				destTile = HomeTeleport.BURTHORPE_LODE_STONE;
				break;
			case 39:
				destTile = HomeTeleport.LUNAR_ISLE_LODE_STONE;
				break;
			case 7:
				destTile = HomeTeleport.BANDIT_CAMP_LODE_STONE;
				break;
			case 50:
				destTile = HomeTeleport.TAVERLY_LODE_STONE;
				break;
			case 40:
				destTile = HomeTeleport.ALKHARID_LODE_STONE;
				break;
			case 51:
				destTile = HomeTeleport.VARROCK_LODE_STONE;
				break;
			case 45:
				destTile = HomeTeleport.EDGEVILLE_LODE_STONE;
				break;
			case 46:
				destTile = HomeTeleport.FALADOR_LODE_STONE;
				break;
			case 48:
				destTile = HomeTeleport.PORT_SARIM_LODE_STONE;
				break;
			case 44:
				destTile = HomeTeleport.DRAYNOR_VILLAGE_LODE_STONE;
				break;
			case 41:
				destTile = HomeTeleport.ARDOUGNE_LODE_STONE;
				break;
			case 43:
				destTile = HomeTeleport.CATHERBY_LODE_STONE;
				break;
			case 52:
				destTile = HomeTeleport.YANILLE_LODE_STONE;
				break;
			case 49:
				destTile = HomeTeleport.SEERS_VILLAGE_LODE_STONE;
				break;
			}
			if (destTile != null)
				player.getActionManager().setAction(new HomeTeleport(destTile));
		} else if (interfaceId == 1214)
			player.getSkills().handleSetupXPCounter(componentId);
		if (interfaceId == 1292) {
			if (componentId == 12)
				Crucible.enterArena(player);
			else if (componentId == 13)
				player.closeInterfaces();
		}
		if (player.getRights() == 2)
			player.sendMessage("InterfaceId " + interfaceId + ", componentId "
					+ componentId + ", slotId " + slotId + ", slotId2 "
					+ slotId2 + ", PacketId: " + packetId);
	}

	public static void openEquipmentBonuses(final Player player, boolean banking) {
		player.stopAll();
		player.getInterfaceManager().sendInventoryInterface(670);
		player.getPackets().sendUnlockIComponentOptionSlots(670, 0, 0, 27, 0,
				1, 2, 3);
		player.getInterfaceManager().sendInterface(667);
		player.getPackets().sendUnlockIComponentOptionSlots(670, 0, 0, 27, 0,
				1, 2, 3);
		player.getPackets().sendConfigByFile(4894, banking ? 1 : 0);
		player.getPackets().sendItems(93, player.getInventory().getItems());
		player.getPackets().sendInterSetItemsOptionsScript(670, 0, 93, 4, 7,
				"Equip", "Compare", "Stats", "Examine");
		player.getPackets().sendIComponentSettings(667, 14, 0, 13, 1030);
		refreshEquipBonuses(player);
		if (banking) {
			player.getTemporaryAttributtes().put("Banking", Boolean.TRUE);
			player.setCloseInterfacesEvent(new Runnable() {
				@Override
				public void run() {
					player.getTemporaryAttributtes().remove("Banking");
				}

			});
		}
	}

	public static void refreshEquipBonuses(Player player) {
		player.getPackets().sendIComponentText(667, 28,
				"Stab: +" + player.getCombatDefinitions().getBonuses()[0]);
		player.getPackets().sendIComponentText(667, 29,
				"Slash: +" + player.getCombatDefinitions().getBonuses()[1]);
		player.getPackets().sendIComponentText(667, 30,
				"Crush: +" + player.getCombatDefinitions().getBonuses()[2]);
		player.getPackets().sendIComponentText(667, 31,
				"Magic: +" + player.getCombatDefinitions().getBonuses()[3]);
		player.getPackets().sendIComponentText(667, 32,
				"Range: +" + player.getCombatDefinitions().getBonuses()[4]);
		player.getPackets().sendIComponentText(667, 33,
				"Stab: +" + player.getCombatDefinitions().getBonuses()[5]);
		player.getPackets().sendIComponentText(667, 34,
				"Slash: +" + player.getCombatDefinitions().getBonuses()[6]);
		player.getPackets().sendIComponentText(667, 35,
				"Crush: +" + player.getCombatDefinitions().getBonuses()[7]);
		player.getPackets().sendIComponentText(667, 36,
				"Magic: +" + player.getCombatDefinitions().getBonuses()[8]);
		player.getPackets().sendIComponentText(667, 37,
				"Range: +" + player.getCombatDefinitions().getBonuses()[9]);
		player.getPackets()
				.sendIComponentText(
						667,
						38,
						"Summoning: +"
								+ player.getCombatDefinitions().getBonuses()[10]);
		player.getPackets()
				.sendIComponentText(
						667,
						39,
						"Absorb Melee: +"
								+ player.getCombatDefinitions().getBonuses()[CombatDefinitions.ABSORVE_MELEE_BONUS]
								+ "%");
		player.getPackets()
				.sendIComponentText(
						667,
						40,
						"Absorb Magic: +"
								+ player.getCombatDefinitions().getBonuses()[CombatDefinitions.ABSORVE_MAGE_BONUS]
								+ "%");
		player.getPackets()
				.sendIComponentText(
						667,
						41,
						"Absorb Ranged: +"
								+ player.getCombatDefinitions().getBonuses()[CombatDefinitions.ABSORVE_RANGE_BONUS]
								+ "%");
		player.getPackets().sendIComponentText(667, 42,
				"Strength: " + player.getCombatDefinitions().getBonuses()[14]);
		player.getPackets()
				.sendIComponentText(
						667,
						43,
						"Ranged Str: "
								+ player.getCombatDefinitions().getBonuses()[15]);
		player.getPackets().sendIComponentText(667, 44,
				"Prayer: +" + player.getCombatDefinitions().getBonuses()[16]);
		player.getPackets().sendIComponentText(
				667,
				45,
				"Magic Damage: +"
						+ player.getCombatDefinitions().getBonuses()[17] + "%");
	}

	public static void sendRemove(Player player, int slotId) {
		if (slotId >= 15)
			return;
		player.stopAll(false, false);
		Item item = player.getEquipment().getItem(slotId);
		if (item == null
				|| !player.getInventory().addItem(item.getId(),
						item.getAmount()))
			return;
		player.getEquipment().getItems().set(slotId, null);
		player.getEquipment().refresh(slotId);
		player.getAppearence().generateAppearenceData();
		if (Runecrafting.isTiara(item.getId()))
			player.getPackets().sendConfig(491, 0);
		if (slotId == 3)
			player.getCombatDefinitions().desecreaseSpecialAttack(0);
	}

	public static boolean sendWear(Player player, int slotId, int itemId) {
		if (player.hasFinished() || player.isDead())
			return false;
		player.stopAll(false, false);
		Item item = player.getInventory().getItem(slotId);
		String itemName = item.getDefinitions() == null ? "" : item
				.getDefinitions().getName().toLowerCase();
		if (item == null || item.getId() != itemId)
			return false;
		if (item.getDefinitions().isNoted()
				|| !item.getDefinitions().isWearItem(
						player.getAppearence().isMale())) {
			player.getPackets().sendGameMessage("You can't wear that.");
			return true;
		}
		for (String strings : Settings.DONATOR_ITEMS) {
			if (itemName.contains(strings) && !player.isDonator()) {
				player.getPackets().sendGameMessage(
						"You need to be a donator to equip " + itemName + ".");
				return true;
			}
		}
		for (String strings : Settings.EXTREME_DONATOR_ITEMS) {
			if (itemName.contains(strings) && !player.isExtremeDonator()) {
				player.getPackets().sendGameMessage(
						"You need to be a extreme donator to equip " + itemName
								+ ".");
				return true;
			}
		}
		for (String strings : Settings.EARNED_ITEMS) {
			if (itemName.contains(strings) && player.getRights() <= 1) {
				player.getPackets().sendGameMessage(
						"You must earn " + itemName + ".");
				return true;
			}
		}
		/*
		 * for (String strings : Settings.VOTE_REQUIRED_ITEMS) { if
		 * (itemName.toLowerCase().contains(strings) && !player.hasVoted()) {
		 * player
		 * .getPackets().sendGameMessage("You need to vote to wear the prod item "
		 * +itemName+" for 24 hours, type ::vote to vote."); return true; } }
		 */
		int targetSlot = Equipment.getItemSlot(itemId);
		if (targetSlot == -1) {
			player.getPackets().sendGameMessage("You can't wear that.");
			return true;
		}
		if (!ItemConstants.canWear(item, player))
			return true;
		boolean isTwoHandedWeapon = targetSlot == 3
				&& Equipment.isTwoHandedWeapon(item);
		if (isTwoHandedWeapon && !player.getInventory().hasFreeSlots()
				&& player.getEquipment().hasShield()) {
			player.getPackets().sendGameMessage(
					"Not enough free space in your inventory.");
			return true;
		}
		HashMap<Integer, Integer> requiriments = item.getDefinitions()
				.getWearingSkillRequiriments();
		boolean hasRequiriments = true;
		if (requiriments != null) {
			for (int skillId : requiriments.keySet()) {
				if (skillId > 24 || skillId < 0)
					continue;
				int level = requiriments.get(skillId);
				if (level < 0 || level > 120)
					continue;
				if (player.getSkills().getLevelForXp(skillId) < level) {
					if (hasRequiriments) {
						player.getPackets()
								.sendGameMessage(
										"You are not high enough level to use this item.");
					}
					hasRequiriments = false;
					String name = Skills.SKILL_NAME[skillId].toLowerCase();
					player.getPackets().sendGameMessage(
							"You need to have a"
									+ (name.startsWith("a") ? "n" : "") + " "
									+ name + " level of " + level + ".");
				}

			}
		}
		if (!hasRequiriments)
			return true;
		if (!player.getControlerManager().canEquip(targetSlot, itemId))
			return false;
		player.stopAll(false, false);
		player.getInventory().deleteItem(slotId, item);
		if (targetSlot == 3) {
			if (isTwoHandedWeapon && player.getEquipment().getItem(5) != null) {
				if (!player.getInventory().addItem(
						player.getEquipment().getItem(5).getId(),
						player.getEquipment().getItem(5).getAmount())) {
					player.getInventory().getItems().set(slotId, item);
					player.getInventory().refresh(slotId);
					return true;
				}
				player.getEquipment().getItems().set(5, null);
			}
		} else if (targetSlot == 5) {
			if (player.getEquipment().getItem(3) != null
					&& Equipment.isTwoHandedWeapon(player.getEquipment()
							.getItem(3))) {
				if (!player.getInventory().addItem(
						player.getEquipment().getItem(3).getId(),
						player.getEquipment().getItem(3).getAmount())) {
					player.getInventory().getItems().set(slotId, item);
					player.getInventory().refresh(slotId);
					return true;
				}
				player.getEquipment().getItems().set(3, null);
			}

		}
		if (player.getEquipment().getItem(targetSlot) != null
				&& (itemId != player.getEquipment().getItem(targetSlot).getId() || !item
						.getDefinitions().isStackable())) {
			if (player.getInventory().getItems().get(slotId) == null) {
				player.getInventory()
						.getItems()
						.set(slotId,
								new Item(player.getEquipment()
										.getItem(targetSlot).getId(), player
										.getEquipment().getItem(targetSlot)
										.getAmount()));
				player.getInventory().refresh(slotId);
			} else
				player.getInventory().addItem(
						new Item(player.getEquipment().getItem(targetSlot)
								.getId(), player.getEquipment()
								.getItem(targetSlot).getAmount()));
			player.getEquipment().getItems().set(targetSlot, null);
		}
		if (targetSlot == Equipment.SLOT_AURA)
			player.getAuraManager().removeAura();
		int oldAmt = 0;
		if (player.getEquipment().getItem(targetSlot) != null) {
			oldAmt = player.getEquipment().getItem(targetSlot).getAmount();
		}
		Item item2 = new Item(itemId, oldAmt + item.getAmount());
		player.getEquipment().getItems().set(targetSlot, item2);
		player.getEquipment().refresh(targetSlot,
				targetSlot == 3 ? 5 : targetSlot == 3 ? 0 : 3);
		player.getAppearence().generateAppearenceData();
		player.getPackets().sendSound(2240, 0, 1);
		if (targetSlot == 3)
			player.getCombatDefinitions().desecreaseSpecialAttack(0);
		player.getCharges().wear(targetSlot);
		return true;
	}

	public static void sendWear(Player player, int[] slotIds) {
		if (player.hasFinished() || player.isDead())
			return;
		boolean worn = false;
		Item[] copy = player.getInventory().getItems().getItemsCopy();
		for (int slotId : slotIds) {
			Item item = player.getInventory().getItem(slotId);
			if (item == null)
				continue;
			if (sendWear2(player, slotId, item.getId()))
				worn = true;
		}
		player.getInventory().refreshItems(copy);
		if (worn) {
			player.getAppearence().generateAppearenceData();
			player.getPackets().sendSound(2240, 0, 1);
		}
	}

	public static boolean sendWear2(Player player, int slotId, int itemId) {
		if (player.hasFinished() || player.isDead())
			return false;
		player.stopAll(false, false);
		Item item = player.getInventory().getItem(slotId);
		if (item == null || item.getId() != itemId)
			return false;
		if (item.getDefinitions().isNoted()
				|| !item.getDefinitions().isWearItem(
						player.getAppearence().isMale()) && itemId != 4084) {
			player.getPackets().sendGameMessage("You can't wear that.");
			return false;
		}
		String itemName = item.getDefinitions() == null ? "" : item
				.getDefinitions().getName().toLowerCase();
		for (String strings : Settings.DONATOR_ITEMS) {
			if (itemName.contains(strings) && !player.isDonator()) {
				player.getPackets().sendGameMessage(
						"You need to be a donator to equip " + itemName + ".");
				return false;
			}
		}
		for (String strings : Settings.EXTREME_DONATOR_ITEMS) {
			if (itemName.contains(strings) && !player.isExtremeDonator()) {
				player.getPackets().sendGameMessage(
						"You need to be a extreme donator to equip " + itemName
								+ ".");
				return true;
			}
		}
		for (String strings : Settings.EARNED_ITEMS) {
			if (itemName.contains(strings) && player.getRights() <= 1) {
				player.getPackets().sendGameMessage(
						"You must earn " + itemName + ".");
				return true;
			}
		}
		/*
		 * for (String strings : Settings.VOTE_REQUIRED_ITEMS) { if
		 * (itemName.toLowerCase().contains(strings) && !player.hasVoted()) {
		 * player
		 * .getPackets().sendGameMessage("You need to vote to wear the prod item "
		 * +itemName+" for 24 hours, type ::vote to vote."); return true; } }
		 */
		int targetSlot = Equipment.getItemSlot(itemId);
		if (itemId == 4084)
			targetSlot = 3;
		if (targetSlot == -1) {
			player.getPackets().sendGameMessage("You can't wear that.");
			return false;
		}
		if (!ItemConstants.canWear(item, player))
			return false;
		boolean isTwoHandedWeapon = targetSlot == 3
				&& Equipment.isTwoHandedWeapon(item);
		if (isTwoHandedWeapon && !player.getInventory().hasFreeSlots()
				&& player.getEquipment().hasShield()) {
			player.getPackets().sendGameMessage(
					"Not enough free space in your inventory.");
			return false;
		}
		HashMap<Integer, Integer> requiriments = item.getDefinitions()
				.getWearingSkillRequiriments();
		boolean hasRequiriments = true;
		if (requiriments != null) {
			for (int skillId : requiriments.keySet()) {
				if (skillId > 24 || skillId < 0)
					continue;
				int level = requiriments.get(skillId);
				if (level < 0 || level > 120)
					continue;
				if (player.getSkills().getLevelForXp(skillId) < level) {
					if (hasRequiriments)
						player.getPackets()
								.sendGameMessage(
										"You are not high enough level to use this item.");
					hasRequiriments = false;
					String name = Skills.SKILL_NAME[skillId].toLowerCase();
					player.getPackets().sendGameMessage(
							"You need to have a"
									+ (name.startsWith("a") ? "n" : "") + " "
									+ name + " level of " + level + ".");
				}

			}
		}
		if (!hasRequiriments)
			return false;
		if (!player.getControlerManager().canEquip(targetSlot, itemId))
			return false;
		player.getInventory().getItems().remove(slotId, item);
		if (targetSlot == 3) {
			if (isTwoHandedWeapon && player.getEquipment().getItem(5) != null) {
				if (!player.getInventory().getItems()
						.add(player.getEquipment().getItem(5))) {
					player.getInventory().getItems().set(slotId, item);
					return false;
				}
				player.getEquipment().getItems().set(5, null);
			}
		} else if (targetSlot == 5) {
			if (player.getEquipment().getItem(3) != null
					&& Equipment.isTwoHandedWeapon(player.getEquipment()
							.getItem(3))) {
				if (!player.getInventory().getItems()
						.add(player.getEquipment().getItem(3))) {
					player.getInventory().getItems().set(slotId, item);
					return false;
				}
				player.getEquipment().getItems().set(3, null);
			}

		}
		if (player.getEquipment().getItem(targetSlot) != null
				&& (itemId != player.getEquipment().getItem(targetSlot).getId() || !item
						.getDefinitions().isStackable())) {
			if (player.getInventory().getItems().get(slotId) == null) {
				player.getInventory()
						.getItems()
						.set(slotId,
								new Item(player.getEquipment()
										.getItem(targetSlot).getId(), player
										.getEquipment().getItem(targetSlot)
										.getAmount()));
			} else
				player.getInventory()
						.getItems()
						.add(new Item(player.getEquipment().getItem(targetSlot)
								.getId(), player.getEquipment()
								.getItem(targetSlot).getAmount()));
			player.getEquipment().getItems().set(targetSlot, null);
		}
		if (targetSlot == Equipment.SLOT_AURA)
			player.getAuraManager().removeAura();
		int oldAmt = 0;
		if (player.getEquipment().getItem(targetSlot) != null) {
			oldAmt = player.getEquipment().getItem(targetSlot).getAmount();
		}
		Item item2 = new Item(itemId, oldAmt + item.getAmount());
		player.getEquipment().getItems().set(targetSlot, item2);
		player.getEquipment().refresh(targetSlot,
				targetSlot == 3 ? 5 : targetSlot == 3 ? 0 : 3);
		if (targetSlot == 3)
			player.getCombatDefinitions().desecreaseSpecialAttack(0);
		player.getCharges().wear(targetSlot);
		return true;
	}

	public static void submitSpecialRequest(final Player player) {
		CoresManager.fastExecutor.schedule(new TimerTask() {
			@Override
			public void run() {
				try {
					WorldTasksManager.schedule(new WorldTask() {
						@Override
						public void run() {
							player.getCombatDefinitions()
									.switchUsingSpecialAttack();
						}
					}, 0);
				} catch (Throwable e) {
					Logger.handle(e);
				}
			}
		}, 200);
	}
}